1. 程式人生 > >Could not open JPA EntityManager for transaction

Could not open JPA EntityManager for transaction

原因: 資料庫的連結預設的超時時間是8個小時,如果在8個小時裡沒有訪問,那麼這個連線就會被回收

如下配置tomcat連線池

spring.datasource.tomcat.max-active=100
spring.datasource.tomcat.max-idle=30
spring.datasource.tomcat.max-age=18000000
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.num-tests-per-eviction-run=3
spring.datasource.tomcat.validation-query=select 1
spring.datasource.tomcat.validation-query-timeout=10000
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.initial-size=5
spring.datasource.tomcat.remove-abandoned=true
spring.datasource.tomcat.remove-abandoned-timeout=82800
spring.datasource.tomcat.time-between-eviction-runs-millis=600000
spring.datasource.tomcat.log-abandoned=true