问题: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,通常是自动注入的。

所以,我们只需要按照提示,将“com.mysql.jdbc.Driver”驱动改为“com.mysql.cj.jdbc.Driver”。

配置如下:

spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: xxx
password: xxx
url: jdbc:mysql://localhost:3306/xxxuseUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐