Reputation: 562
Trying to connect to the mysql database and get this error:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.MysqlDataSource
My dependency in pom file:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.24</version>
</dependency>
My connection to the db:
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
Upvotes: 1
Views: 1290
Reputation: 562
I found a solution. I am working with IntelliJ IDEA and for resolving this you need just Reload All Maven Projects.
Upvotes: 1