Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver


mysql jdbc Driver this is deprecated message
Log Message:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

The above message is to let you know that the class com.mysql.jdbc.Driver is deprecated and you should be using com.mysql.cj.jdbc.Driver instead in your project.

It's important to note that the newer driver class is automatically registered via the Service Provider Interface (SPI) and you generally do not need to manually load the driver class.

To remove this message in your Spring Boot application, you can do the following:

  • Make sure you are using the proper dependency for mySQL in your pom.xml or build.gradle file.

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.x.xx</version>
    </dependency>
  • In the Spring Boot configuration file application.properties make sure you are using,

    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

    Insead of,

    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  • If you using applciation.yml file
    spring:
      datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
    

Read more:

You can read more about the com.mysql.jdbc.Driver being deprecation and the usage of com.mysql.cj.jdbc.Driver in the below links:

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap