Tôi có một ứng dụng có sử dụng lò xo khởi động, JPA-hiberanate với mysql.I đang nhận log lỗi nàyKết nối với Db chết sau> 4 <24 trong JPA lò xo khởi động ngủ đông
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.
Đây là của tôi application.properties
# DataSource settings: set here configurations for the database connection
spring.datasource.url = jdbc:mysql://localhost:3306/test
spring.datasource.username = test
spring.datasource.password = test
spring.datasource.driverClassName = com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.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.MySQL5Dialect
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
Để giải quyết vấn đề này, tôi có thể sử dụng
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
Nhưng tôi đã kiểm tra rằng nó không phải là recommended. Vì vậy, bất kỳ ai cũng có thể đề xuất tôi nên làm gì để khắc phục lỗi này
Hãy xem bài đăng sau. http://hibernatedb.blogspot.in/2009/05/automatic-reconnect-from-hibernate-to.html, đây là liên kết nhận xét hấp dẫn từ http://stackoverflow.com/questions/2077081/connection-with -mysql-is-being-aborted-automaticly-how-to-configure-connector-j –
@KennethClark Tôi đang sử dụng spring-boot không spring nên những thứ này sẽ không giúp ích nhiều cho tôi. Và tôi cũng không biết nhiều về mùa xuân . – Soham
Khởi động mùa xuân dựa trên Spring, vì vậy nếu bạn sử dụng Spring Boot, tất nhiên bạn cũng đang sử dụng Spring. Bạn nên đọc thêm về những điều cơ bản của Spring Boot, nếu bạn không biết điều đó. – dunni