Jenkins跑集成测试报错,本地测试通过。数据库脚本是最新的,登录docker查看有最新的表
Error Message
Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Stacktrace
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
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.
Caused by: java.net.SocketTimeoutException: connect timed out
Spring Boot的项目,用到了JPA。在CI服务器,用 mysql -hprivateAddress -u username -p
可以连上
privateAddress是docker 里面的MySQL的custom的bridge地址。show tables
也可以看到最新的表。
CI服务器只装了MySQL client core没装server,docker里装的MySQL官方镜像。
Spring Boot application.properties
配置相关行
spring.datasource.url=jdbc:mysql://privateAddress:3306/dems?useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=none
想不明白是哪里的问题。