Spring Boot HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl

1、报错信息

2020-05-31 14:17:38.250  WARN 3940 --- [nio-8080-exec-8] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@6b95be22 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-31 14:17:48.253  WARN 3940 --- [nio-8080-exec-8] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@48056978 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-31 14:17:58.257  WARN 3940 --- [nio-8080-exec-8] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to validate connection com.mysql.cj.jdbc.ConnectionImpl@2ae7e8f0 (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value.
2020-05-31 14:17:58.302 ERROR 3940 --- [nio-8080-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30106ms.

com.mysql.cj.exceptions.ConnectionIsClosedException: No operations allowed after connection closed.
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]

2、解决办法
在application.yml配置文件加上如下连接池配置信息

# Hikari 连接池配置
hikari:
  minimum-idle: 3  # 最小空闲连接数量
  maximum-pool-size: 5  # 连接池最大连接数,默认是10
  max-lifetime: 1800000  # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
  connection-test-query: SELECT 1

你可能感兴趣的:(Java)