I've got the following class in my Spring Boot app:
@Configuration
public class JDBCTokenConfig {
...
@Value("${spring.datasource.driver-class-name}")
private String dbDriverClassName;
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(dbDriverClassName);
dataSource.setUrl(datasourceUrl);
dataSource.setUsername(dbUsername);
dataSource.setPassword(dbPassword);
return dataSource;
}
I've also got the following in my pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
In my application.properties I have:
...
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Yet I'm seeing the following error:
Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.cj.jdbc.Driver]
Is this the correct the drive class path? Or anything else?