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.
看了很多博客说把mysql jdbc驱动名改成 cj的那个
于是试了试
不过还是继续报错
MySQLNonTransientConnectionException
通过浏览很多人的博客说把配置一下mysql驱动依赖版本,因为maven在不定义版本的情况下载自动下载最新版本
于是我又在pom.xml配置文件添加依赖版本
结果:
最后:看到别的博客是这样解释的
com.mysql.jdbc.Driver 是 mysql-connector-java 5中的,
com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6版本以上的
于是我想我的mysql版本是什么呢
查询mysql版本
SELECT VERSION();
是版本5,于是我又把application.yml中mysql jdbc驱动名改回来了
最终运行成功了