mysql的驅動類com.mysql.jdbc.Driver過時了,需要用com.mysql.cj.jdbc.Driver代替


springboot項目整合mybatis,配置文件如下:

server:
  port: 8081
mybatis:
  config-location: classpath:mybatis/mybatis-config.xml   #mybatis配置文件所在路徑
  type-aliases-package: com.yuanqiao.entities     #所有entity別名類所在包
  mapper-locations: classpath:mybatis/mapper/*.xml
spring:
  application:
    name: swaggerdemo
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    username: root
    password: 123456
    dbcp2:
      min-idle: 5         #數據庫連接池的最小維持連接數
      initial-size: 5      #初始化連接數
      max-total: 5            #最大連接數
      max-wait-millis: 200      #等待連接獲取的最大超時時間

做sql查詢的時候,提示com.mysql.jdbc.Driver已經棄用了。

 

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5540e55e] was not registered for synchronization because synchronization is not active
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.
2019-07-20 16:16:42.533 INFO 59084 --- [nio-8081-exec-2] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@366b8e6b] will not be managed by Spring
==> Preparing: select * from user where id = ?
==> Parameters: 1(Integer)
<== Columns: id, name, sex, age
<== Row: 1, zhangsan, male, 22
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5540e55e]

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM