user7544815
user7544815

Reputation:

Spring mysql-connector version incompatibility

i am coding a maven project with spring, the default mysql-connector is version 6.0.5, and whenever i run the app on server the stack trace tells me that "Could not load JDBC driver class [com.mysql.jdbc.Driver]". So i add as external library mysql-connector downloaded from mvnrepository.com version 5.1.40, add the dependency code to pom.xml and then it works! How can i fix it using v 6.0.5?

thanks

Upvotes: 0

Views: 2916

Answers (1)

user4046031
user4046031

Reputation:

If I understand you correctly you downloaded manually mysql connector, and added it as library.

Add dependency in pom.xml and reimport maven dependencies.

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>6.0.5</version>
</dependency>

You should checkout if your application.properties are set correctly, e.g:

 spring.datasource.url=jdbc:mysql://localhost/jpa_example
 spring.datasource.username=root
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

Upvotes: 1

Related Questions