Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver
IDEA报错在非池化数据源上设置驱动程序时出错
CMD命令登录MYSQL
CMD命令登录MYSQL,查看mysql版本,我的是8.0.27
- win+r进入cmd
C:\Users\ws199>mysql -uroot -p Enter password: ****
- 查看版本
mysql> select version() -> ; +-----------+ | version() | +-----------+ | 8.0.27 | +-----------+ 1 row in set (0.01 sec)
查看MySQL依赖
MySQL依赖导入高于自己本地的MySQL版本
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.30</version> </dependency>
mysql版本超过8.0
超过8.0版本的就要在com.mysql.jdbc.Driver加入cj
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
mysql版本低于8.0
<property name="driver" value="com.mysql.jdbc.Driver"/>