在spring-boot jpa hibernate中,在> 4 <24之后连接到Db
我有一个使用spring-boot,jpa-hiberanate与mysql的应用程序。我收到此错误日志
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 56,006,037 milliseconds ago. The last packet sent successfully to the server was 56,006,037 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
这是我的application.properties
# DataSource settings: set here configurations for the database connectionspring.datasource.url = jdbc:mysql://localhost:3306/testspring.datasource.username = test spring.datasource.password = test spring.datasource.driverClassName = com.mysql.jdbc.Driver# Specify the DBMSspring.jpa.database = MYSQL# Show or not log for each sql queryspring.jpa.show-sql = true# Hibernate settings are prefixed with spring.jpa.hibernate.*spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialectspring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
要解决这个问题,我可以使用
spring.datasource.testOnBorrow=truespring.datasource.validationQuery=SELECT 1
但我检查了它不推荐。所以任何人都可以建议我应该怎么做才能克服这个错误
莫回无