全栈开发项目编程系列讲解

开源项目代码链接 https://github.com/singerdmx/BulletJournal

如果你对开源项目开发感兴趣,欢迎联系我加入我们的开发项目

Playlist 戳这里

欢迎给视频点赞和订阅YouTube频道 :innocent:


参考资料

  1. https://todoist.com/
  1. https://kanban.ist/demo
  2. https://www.chuangkit.com/sj-pi4-si262-or0-pt1-pn1.html
  3. https://github.com/totaljs/openplatform-todo
2 Likes

要求大家在这个阶段能够成功跑 docker-compose 并启动2个container

还有个启动稳定性问题可以参考

根据 https://docs.docker.com/compose/compose-file/

Version 3 no longer supports the condition form of depends_on .

1 Like

https://docs.spring.io/autorepo/docs/spring-boot/1.1.0.M1/reference/html/howto-database-initialization.html

可以结合下面这个视频来看

https://mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/

这里有关 SSO 的基础知识可以看下 OAuth 和 SSO

pgadmin 添加server总是出错 (因为端口占用, 5432改成5433)

试图从terminal直接运行postgres sql, 输入密码docker也报错

MacBook-Air:BulletJournal $ sudo -u postgres psql
Password for user postgres: 
psql: FATAL:  password authentication failed for user "postgres"

另外terminal端的运行记录如下

Starting db ... done
Starting springboot_app ... done
Starting react_app      ... done
Attaching to db, springboot_app, react_app
db            | 
db            | PostgreSQL Database directory appears to contain a database; Skipping initialization
db            | 
db            | 2020-02-03 06:05:21.161 UTC [1] LOG:  starting PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db            | 2020-02-03 06:05:21.164 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db            | 2020-02-03 06:05:21.164 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db            | 2020-02-03 06:05:21.175 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db            | 2020-02-03 06:05:21.490 UTC [26] LOG:  database system was shut down at 2020-02-03 05:57:51 UTC
db            | 2020-02-03 06:05:21.646 UTC [1] LOG:  database system is ready to accept connections
springboot_app | 
springboot_app |   .   ____          _            __ _ _
springboot_app |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
springboot_app | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
springboot_app |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
springboot_app |   '  |____| .__|_| |_|_| |_\__, | / / / /
springboot_app |  =========|_|==============|___/=/_/_/_/
springboot_app |  :: Spring Boot ::             (v2.3.0.M1)
springboot_app | 
springboot_app | 2020-02-03 06:05:35.278  INFO 1 --- [           main] c.b.BulletjournalApplication             : Starting BulletjournalApplication on dd917a17d7de with PID 1 (/app started by root in /)
springboot_app | 2020-02-03 06:05:35.301  INFO 1 --- [           main] c.b.BulletjournalApplication             : The following profiles are active: dev
springboot_app | 2020-02-03 06:05:41.572  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
springboot_app | 2020-02-03 06:05:41.972  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 334ms. Found 2 JPA repository interfaces.
springboot_app | 2020-02-03 06:05:43.883  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
springboot_app | 2020-02-03 06:05:45.402  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
springboot_app | 2020-02-03 06:05:45.493  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
springboot_app | 2020-02-03 06:05:45.495  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
springboot_app | 2020-02-03 06:05:45.930  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
springboot_app | 2020-02-03 06:05:45.931  INFO 1 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 10102 ms
springboot_app | 2020-02-03 06:05:47.390  INFO 1 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
springboot_app | 2020-02-03 06:05:47.657  INFO 1 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
springboot_app | 2020-02-03 06:05:48.726  INFO 1 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate Core {5.4.9.Final}
springboot_app | 2020-02-03 06:05:49.851  WARN 1 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
springboot_app | 2020-02-03 06:05:50.336  INFO 1 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
springboot_app | 2020-02-03 06:05:50.976  INFO 1 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
springboot_app | 2020-02-03 06:05:51.611  INFO 1 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
springboot_app | 2020-02-03 06:05:51.742  INFO 1 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
springboot_app | 2020-02-03 06:05:57.553  INFO 1 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
springboot_app | 2020-02-03 06:05:57.618  INFO 1 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
springboot_app | 2020-02-03 06:05:59.307  INFO 1 --- [           main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
springboot_app | 2020-02-03 06:06:01.243  INFO 1 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
springboot_app | 2020-02-03 06:06:01.372  INFO 1 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
springboot_app | 2020-02-03 06:06:01.551  INFO 1 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
springboot_app | 2020-02-03 06:06:02.370  INFO 1 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
springboot_app | 2020-02-03 06:06:03.064  INFO 1 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
springboot_app | 2020-02-03 06:06:03.224  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
springboot_app | 2020-02-03 06:06:03.236  INFO 1 --- [           main] c.b.BulletjournalApplication             : Started BulletjournalApplication in 31.377 seconds (JVM running for 34.74)

docker ps 看下输出

CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS                    PORTS                              NAMES
e620170ca279        mwangxx/bulletjournal-frontend:latest   "nginx -g 'daemon of…"   52 minutes ago      Up 12 minutes             0.0.0.0:80->80/tcp                 react_app
dd917a17d7de        mwangxx/bulletjournal-backend:latest    "java -cp app:app/li…"   52 minutes ago      Up 12 minutes             0.0.0.0:8080->8080/tcp             springboot_app
835a3591a4f6        postgres                                "docker-entrypoint.s…"   52 minutes ago      Up 12 minutes (healthy)   5432/tcp, 0.0.0.0:5433->5433/tcp   db
8fb

你这个 5432 是怎么回事?
贴下我的

CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS                    PORTS                            NAMES
e201e58d1d72        xcode1024/auth-proxy:latest             "/bin/start.sh"          25 seconds ago      Up 24 seconds             0.0.0.0:80->80/tcp               auth-proxy
6b6ff4bb025d        mwangxx/bulletjournal-frontend:latest   "nginx -g 'daemon of…"   26 seconds ago      Up 25 seconds             80/tcp, 0.0.0.0:3000->3000/tcp   react_app
f3ae3d29feb9        mwangxx/bulletjournal-backend:latest    "java -cp app:app/li…"   27 seconds ago      Up 25 seconds             0.0.0.0:8080->8080/tcp           springboot_app
a03aa9d17140        postgres                                "docker-entrypoint.s…"   38 seconds ago      Up 36 seconds (healthy)   0.0.0.0:5432->5432/tcp           db

我觉得你先看下为啥 5432 占用, 这个不应该

应该有4个container,是不是没有pull最新的?

嗯因为我改了docker-compose.yml的这里

database:
    image: postgres
    container_name: db
    hostname: postgres
    ports:
      - "5433:5433"

否则运行会报错

Recreating db ... error

ERROR: for db  Cannot start service database: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use

ERROR: for database  Cannot start service database: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use
ERROR: Encountered errors while bringing up the project.

刚pull了最新的,原来少了个auth-proxy 的container

你得先解决占用问题,你找不到谁在占用吗?

嗯找到了, 正在处理

sudo lsof -i :5432
Password:
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
postgres  66 postgres    4u  IPv6 0xd93867135d2259f5      0t0  TCP *:postgresql (LISTEN)
postgres  66 postgres    5u  IPv4 0xd93867135d22c6f5      0t0  TCP *:postgresql (LISTEN)

你是不是自己曾经本地安装过 PostgreSQL,而且还在跑着?

我不记得了…
正在试图kill process, 但好像没那么简单

MacBook-Air:BulletJournal $ sudo kill -9 66
MacBook-Air:BulletJournal $ sudo lsof -i :5432
COMMAND    PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
postgres 12817 postgres    4u  IPv6 0xd93867137910b6b5      0t0  TCP *:postgresql (LISTEN)
postgres 12817 postgres    5u  IPv4 0xd938671373cb33f5      0t0  TCP *:postgresql (LISTEN)
1 Like