业务逻辑是:推送按钮-处理推送逻辑-往第三方系统推送文件(大文件几十分钟)-推送完成-记录推送状态-操作完成
在推送完成往数据库写入数据的时候抛出如下异常:
com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 5,401,659 milliseconds ago. The last packet sent successfully to the server was 5,401,672 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.
根据异常内容可知是数据库连接超时导致的,建议用'autoReconnect=true' ,但是数据库连接配置加了这个也没用,后面又想到用连接池加入如下配置:
druid: maxWait: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false