zoukankan      html  css  js  c++  java
  • Spring Boot 2程序不能加载 com.mysql.jdbc.Driver 问题

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

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

    刚开始以为是 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 片段

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.6.RELEASE</version>
            <relativePath /> <!-- lookup parent from repository -->
        </parent>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
    
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>provided</scope>
        </dependency>    
  • 相关阅读:
    安装TeX字体
    【数学】对数的底为什么不能为负数
    算法设计的要求
    Windows HTTP Services
    为什么分母不能为0
    循环小数怎样变分数
    在win7环境下批量修改文件权限
    算法复杂度的极限证明
    深入理解 【有理数】、【无理数】、【虚数】
    kettle连接sqlserver
  • 原文地址:https://www.cnblogs.com/harrychinese/p/springboot_cannot_load_jdbc_driver.html
Copyright © 2011-2022 走看看