java.lang.ClassNotFoundException:com.mysql.cj.jdbc.MysqlDataSource
正在尝试连接到mysql数据库并出现以下错误: 原因:org.springframework.beans.BeanInstantiationException: 未能实例化[javax.sql.DataSource]:工厂方法 “dataSource”引发异常;嵌套异常是 java.lang.RuntimeException:java.lang.ClassNotFoundException: com.mysql.cj.jdbc.MysqlDataSource pom文件中的我的依赖项:java.lang.ClassNotFoundException:com.mysql.cj.jdbc.MysqlDataSource,java,mysql,spring,database,Java,Mysql,Spring,Database,正在尝试连接到mysql数据库并出现以下错误: 原因:org.springframework.beans.BeanInstantiationException: 未能实例化[javax.sql.DataSource]:工厂方法 “dataSource”引发异常;嵌套异常是 java.lang.RuntimeException:java.lang.ClassNotFoundException: com.mysql.cj.jdbc.MysqlDataSource pom文件中的我的依赖项: <
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.24</version>
</dependency>
我找到了解决办法。
我正在与IntelliJ IDEA合作,为了解决这个问题,您只需重新加载所有Maven项目
去年,由于……原因,intelliJ删除了maven自动导入功能。在编辑java文件时,您还应该看到一个小标记,指示需要进行maven重新导入。
datasource:
dataSourceClassName: com.mysql.cj.jdbc.MysqlDataSource
url: jdbc:mysql://localhost:3306/test?serverTimezone=UTC&verifyServerCertificate=false&useSSL=false&allowPublicKeyRetrieval=true
serverName: localhost
databaseName: test
username: root
password: mynewpassword
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
testWhileIdle: true
validationQuery: SELECT 1