Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
 

 

1. 第一种问题,没有在application.ym里面设置driver-class-name和url

解决方法:添加以下代码就行了

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=utf-8&useSSL=true
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    show-sql: true

 

2.第二种问题,就是打包成pom文件,但是target里面没有application.yml文件()

我添加了以下代码,编译后发现target里面没有application.yml文件

<packaging>pom</packaging>

<resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>

解决方法:删掉上面的代码,删掉之后重新编译就有了

Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

 

上一篇:CentOS7离线安装nginx-1.18.0完整记录


下一篇:OpenWrt For Support SkyEdge Gilat Modem Configure