2017-08-16 153 views
0

我面臨連接關閉在我的彈簧引導應用程序異常。Spring Boot BrokenPipe /通信異常

這是我的數據庫配置:

# For auto recconect it is necessary 
spring.datasource.tomcat.test-on-borrow = true 
spring.datasource.tomcat.test-while-idle= true 
spring.datasource.tomcat.test-on-return = true 
spring.datasource.tomcat.validationQuery=SELECT 1 

spring.datasource.tomcat.time-between-eviction-runs-millis = 60000 
spring.datasource.tomcat.min-evictable-idle-time-millis = 300000 

spring.datasource.tomcat.min-idle = 10 
spring.datasource.tomcat.max-idle = 100 

# Maximum number of active connections that can be allocated from this pool at the same time. 
spring.datasource.tomcat.max-active = 100 

例外:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:從服務器成功接收最後一個包是66612631 毫秒前。成功發送到服務器的最後一個數據包是66612631毫秒前的 。比'wait_timeout'的值配置的服務器長 。在應用程序中使用之前,應考慮測試連接有效性,或者增加 服務器配置的客戶端超時值,或者使用 連接器/ J連接屬性'autoReconnect = true'來避免此 問題。

java.net.SocketException異常:殘破的管道

我見過很多主題有關啓用autoReconnect的,但它沒有,據我知道的建議。

回答

0

那麼我改變了默認數據源提供程序爲dbcp2,並修復了這個錯誤。

spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource 

# For auto recconect it is necessary 
spring.datasource.dbcp2.test-on-borrow = true 
spring.datasource.dbcp2.test-while-idle = true 
spring.datasource.dbcp2.test-on-return = true 
spring.datasource.dbcp2.validationQuery = SELECT 1 

spring.datasource.dbcp2.time-between-eviction-runs-millis = 60000 
spring.datasource.dbcp2.min-evictable-idle-time-millis = 300000 

spring.datasource.dbcp2.min-idle = 10 
spring.datasource.dbcp2.max-idle = 100 
相關問題