遇到Druid報錯c.a.druid.pool.DruidAbstractDataSource:discard long time none received connection.
其原因是:當程序獲取數據庫連接,對已存在的數據庫連接進行檢查,檢查到空閑時間過久的連接會進行注銷,並報出錯誤提示。
簡單做個記錄叭~
網上很多帖子說大概2個方法可以解決:
1、類文件配置,增加配置(在我這里無效)
@PostConstruct public void init(){ // 處理 discard long time none received connection System.setProperty("druid.mysql.usePingMethod", "false"); }
2、相應調整了mysql的版本(在我這里也無效)
3、在運行參數中增加:-Ddruid.mysql.usePingMethod=false(有效)
nohup java -Ddruid.mysql.usePingMethod=false -jar user-0.0.1-SNAPSHOT.jar --server.port=9092 >user.out &