springboot启动项目报错:Failed to determine a suitable driver class

转载自:https://blog.csdn.net/AinUser/article/details/81533858

第一种情况:

在application.properties/或者application.yml文件中没有添加数据库配置信息

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/read_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: root
    password: 123456
    driver-class-name: com.mysql.jdbc.Driver

第二种情况

yml或者properties文件没有被扫描到

需要在pom文件中<build></build>添加如下

<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
        <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
</resources>

猜你喜欢

转载自blog.csdn.net/ma919755374/article/details/85110112
今日推荐