启动项目报错Communications link failure

spring boot 启动项目时 报错。

Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet successfully received from the server was 319 milliseconds ago.  The last packet sent successfully to the server was 319 milliseconds ago.

报错问题:通信链路故障,简单来说就是没连上数据库

排错方法:
1.首先 看一下数据库是否能连上。如果别人能连上 你连不上。则是数据库是正常的。
就需要排查你的链路和数据库是否在一个网段上。
2.其次查看网络是否正常访问,如果能正常访问则网络正常。

解决方案:
#下面这两个配置,可以在每次连接的时候判断一些连接是否有效

spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-while-idle=true

主要是排查问题出现在哪,再去解决。

发布了5 篇原创文章 · 获赞 5 · 访问量 427

猜你喜欢

转载自blog.csdn.net/weixin_43507846/article/details/104017660