由于无限重连导致日志数据爆满,报的错是
com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/mysql, errorCode 0,
state 08S01 com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
便去查了下阿里巴巴DruidDataSource的重连机制资料,发现没有设置connectionErrorRetryAttempts和timeBetweenConnectErrorMillis和maxWait
connectionErrorRetryAttempts | 连接出错后再尝试连接次数 |
timeBetweenConnectErrorMillis | 关闭空闲连接的检测时间间隔 |
maxWait | 超时等待时间 |
可将BreakAfterAcquireFailure设置为true,connectionErrorRetryAttempts设置为0,maxWait再设置一下就可以避免无限重连了
参考https://blog.csdn.net/qq_36669407/article/details/104744899