spring.freemarker.cache:false spring.datasource.url=jdbc:mysql://localhost/mydb spring.datasource.username=user spring.datasource.password=pass spring.datasource.driver-class-name=com.mysql.jdbc.Driver
im getting this error even with the driver-class-name difined
java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.1.RELEASE.jar:4.2.1.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:153) ~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:119) ~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60] at ......
and it goes on
Driver occurs if there is a disparity between mysql driver class, mysql driver jar version and mysql database version. The java application attempts to load a driver class from the mysql database driver jar. If the driver class is unable to load, the exception Cannot load driver class: com.
If you're using Maven, add this to your pom.xml
:
(Recommended) For MySQL 5.6, 5.7, 8.x
and Java >= 8
use;
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.25</version> </dependency>
(Legacy) For MySQL <= 5.5
or Java <= 7
or JDBC < 4.2
use;
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.49</version> </dependency>
More details on Connector/J versions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With