Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
………………
Caused by: java.sql.SQLException: Connection is closed
服務(wù)器斷網(wǎng)重連后挨厚,JPA 查詢時(shí)會(huì)報(bào)這個(gè)錯(cuò)誤
網(wǎng)上找了好久尸诽,最后發(fā)現(xiàn)添加這個(gè)配置可以解決鬼雀。
在 application.yml 里添加
spring:
datasource:
test-on-borrow: true
validationQuery: SELECT 1
走投無路的同學(xué)硝皂,不妨try one try常挚。
因?yàn)榭吹降奶佣际且幌戮W(wǎng)站機(jī)譯了外國的帖子,我也找不到原作者了稽物,這里就不引用鏈接了