Cause: The validity period of the database connection on the application side is greater than the validity period set by the database itself.
solution:
1. Modify druid configuration (if druid is used)
spring.datasource.druid.validationQuery=select 1
spring.datasource.druid.testWhileIdle=true
spring.datasource.druid.testOnBorrow=true
spring.datasource.druid.testOnReturn=true
PS. This scheme will have a certain impact on performance
Two, modify the database connection configuration
On the database connection, add "&autoReconnect=true&failOverReadOnly=false" configuration
Three, modify the effective time of the database connection
Set on the database configuration, set the effective time of the database connection to be longer, such as 12 hours or 24 hours
Fourth, you can also refer to other methods in this article: https://www.cnblogs.com/jpfss/p/7206912.html