問題描述
我正在做的這個(gè)項(xiàng)目,數(shù)據(jù)庫是跨區(qū)并且不由自己管理的。防火墻會(huì)每隔一段時(shí)間就自動(dòng)斷開數(shù)據(jù)庫連接。
于是需要對application.properties的datasource進(jìn)行配置。Ps:我使用是mybatis連接數(shù)據(jù)庫。
配置及具體含義
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#初始化連接 spring.datasource.initial-size= 10 #最大空閑連接 spring.datasource.max-idle= 20 #最小空閑連接 spring.datasource.min-idle= 5 #最大連接數(shù)量 spring.datasource.max-active= 50 #是否在自動(dòng)回收超時(shí)連接的時(shí)候打印連接的超時(shí)錯(cuò)誤 spring.datasource.log-abandoned= true #是否自動(dòng)回收超時(shí)連接 spring.datasource.remove-abandoned= true #超時(shí)時(shí)間(以秒數(shù)為單位) spring.datasource.remove-abandoned-timeout= 180 ##<!-- 超時(shí)等待時(shí)間以毫秒為單位 6000 毫秒/ 1000 等于 60 秒 --> spring.datasource.max-wait= 1000 spring.datasource.test- while -idle= true #檢測數(shù)據(jù)庫的查詢語句 spring.datasource.validation-query=select 1 from dual spring.datasource.test-on-borrow= true #每隔五分鐘檢測空閑超過 10 分鐘的連接 spring.datasource.min-evictable-idle-time-millis= 600000 spring.datasource.time-between-eviction-runs-millis= 300000 |
以上所述是小編給大家介紹的Spring boot 數(shù)據(jù)庫連接斷線重連問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對服務(wù)器之家網(wǎng)站的支持!
原文鏈接:http://blog.csdn.net/mr_phy/article/details/73323992