小工具知识网

当前位置: 首页 > 行业知识 > Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection;

行业知识

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection;

2026-11-05 11:05:26 来源:互联网转载

 Cause: index.php/tags-1038.html" >org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

————————————————

       出现这个错误的原因很可能是因为mysql版本和sql驱动包的版本不一致导致的,

在pom.xml文件中找到mysql驱动的依赖,如果你的mysql版本是5点几的,驱动的版本就改成5点几,这里我自己的mysql版本是8.0.31,这里推荐的mysql驱动包版本是8.0.30,把版本改一下就行了,

或者如果不是maven环境,就导入相应版本的jar包

注意:不同版本的mysql驱动,application.properties文件的配置可能不同,

这是8点几的mysql版本的配置:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

而5点几的配置为:

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

上一篇:盗版基岩服务器怎么进?

下一篇:揭秘,轶字的正确读音揭秘