spring无法装载mysql_Spring Boot 2程序不能加载 com.mysql.jdbc.Driver 问题

用Spring Boot Starter 向导生成了一个很简单SpringBoot程序, 用到了 MySQL, 总是下面不能加载 Mysql driver class 错误.

Cannot load driver class: com.mysql.jdbc.Driver

36a994266bfd620e300fbee0b1e5b08c.png

刚开始以为是 application.properties 中相关的配置项写法不合规, 发现很正常. 检查了 MySQL jar 文件也很正常. 突然想起之前好像也碰到过同样的问题, 又想了很久, 终于想起上次是因为用了 spring-boot 2.0.5.RELEASE, 换成了 2.0.4.RELEASE 就好了. 这次 Spring Boot Starter 向导生成的是 2.0.6.RELEASE, 改回2.0.4.RELEASE 也好了.

记录一下, 以免将来又碰到同样的问题.

附: application.properties 文件

spring.datasource.url=jdbc:mysql://localhost:3306/world?useUnicode=true&characterEncoding=utf-8

spring.datasource.username=root

spring.datasource.password=root

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

附 pom.xml 片段

org.springframework.boot

spring-boot-starter-parent

2.0.6.RELEASE

org.springframework.boot

spring-boot-starter-jdbc

mysql

mysql-connector-java

provided

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值