根据引入的依赖jar包当中之后,我们会发现,假如按照以前的com.mysql.jdbc.Driver点进去之后,你会发现这样的代码:
package com.mysql.jdbc;
import java.sql.SQLException;
/**
* Backwards compatibility to support apps that call <code>Class.forName("com.mysql.jdbc.Driver");</code>.
*/
public class Driver extends com.mysql.cj.jdbc.Driver {
public Driver() throws SQLException {
super();
}
static {
System.err.println("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.");
}
}
它就是在提示你用另外一个了