Int*_*ced 2 mysql spring-boot jhipster
我想在 JHipster 3.4.2 的开发模式下使用 mySQL。我使用生成器生成了应用程序并安装了 docker 和 docker-compose。当启动docker-compose -f src/main/docker/mysql.yml up并运行应用程序时,./mvnw我会得到堆栈跟踪:
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:528)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:118)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:94)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:388)
at eu.biasion.nbmf.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:66)
at eu.biasion.nbmf.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:49)
at eu.biasion.nbmf.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$17(ExceptionHandlingAsyncTaskExecutor.java:47)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Run Code Online (Sandbox Code Playgroud)
我没有找到有关在开发模式下将 mySQL 与 Jhipster 一起使用的指南。我非常感谢您的任何建议。
如果你想在本地运行的 mvn 项目中使用 Docker 的 MySQL 容器,你需要将 src/main/resources/config/application-dev.yml 更改为指向 Docker 的 IP 而不是 localhost。这让您可以继续使用实时重新加载和 BrowserSync。
要更改的属性是spring.datasource.url。就我而言,Docker 在 192.168.99.100 上运行,因此 application-dev.yml 的更新部分应如下所示:
spring:
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
datasource:
url: jdbc:mysql://192.168.99.100:3306/chat?useUnicode=true&characterEncoding=utf8&useSSL=false
Run Code Online (Sandbox Code Playgroud)