Loading class com.mysql.jdbc.Driver . This is deprecated. The new driver class is com.mysql.cj.jdb
程序员文章站
2024-03-14 17:05:22
...
如果本文对您有所帮助,可以点一下赞????
本文只是学习笔记,欢迎指错,转载标明出处
1、记录一个bug,错误信息如下。
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.
大概意思如下
加载类“com.mysql.jdbc.Driver”。这是弃用。新的驱动程序类是“com.mysql.cj.jdbc.Driver”。驱动程序是通过SPI自动注册的,通常不需要手动加载驱动程序类。但是服务器可以正常启动,就没多留意。
2、可是到了后面把MVC层也都写好了,访问数据库的时候就报错了,新的错误信息如下
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo4.dao.AdminDao.queryById] with root cause
3、当时遇到这个问题有点懵,因为我建立的SpringBoot项目,基础的基本文件都是自动生成的。就没想到是 MySQL的 jar包版本的问题!
4、去到pom.xml,将红框内容修改一下version即可,(我的MySQL的版本是5.5的)
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
5、总结一下,即使是工具自动生成的代码,也可能出错,不能过于依赖工具。
上一篇: 四、数据类型
推荐阅读
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdb
-
Loading class com.mysql.jdbc.Driver . This is deprecated. The new driver class is com.mysql.cj.jdb
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated.
-
spring boot单元测试类的使用.Loading class `com.mysql.jdbc.Driver'. This is deprecated.
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated警告处理,jdbc更新处
-
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdb
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdb
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated 警告异常
-
Loading class `com.mysql.jdbc.Driver'. This is deprecated 警告异常