【Spring中MySQL连接错误】Cannot load driver class: com.mysql.cj.jdbc.Driver

Caused by: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method ‘dataSource’ threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver

Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver

【Spring中MySQL连接错误】Cannot load driver class: com.mysql.cj.jdbc.Driver_第1张图片
这类报错是因为mysql-connector-java.version的版本和连接MySQL不匹配导致的, com.mysql.cj.jdbc.Driver对应的是MySQL8.0, com.mysql.jdbc.Driver对应MySQL5.7, 在pom.xml中配置的时候最好也可以标注一些mysql-connector-java.version的版本, 5.7匹配5.7, 8.0匹配8.0

你可能感兴趣的:(工具,spring,mysql,java)