解决:Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is ......

The following problems occur when the Mybatis project is running:

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.


cause:

mysql version problem

The dependency package I used in the Pom.xml file is version 8.0.32. When connecting to the data driver source, I used com.mysql.jdbc.Driver. After checking, I found that this is the writing method of mysql5.0 version.

 <!-- mysql数据库 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.32</version>
        </dependency>
 <!-- 配置数据库信息,方法一 -->
                <property name="driver" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis"/>
                <property name="username" value="root"/>
                <property name="password" value="root"/>

Solution:

Will

  <property name="driver" value="com.mysql.jdbc.Driver"/>

Change to

  <property name="driver" value="com.mysql.cj.jdbc.Driver"/>

run

Guess you like

Origin blog.csdn.net/qq_53376718/article/details/133361415