无法配置数据源“未指定url属性且无法配置嵌入式数据库”

时间:2019-02-15 11:05:41

标签: java mysql spring spring-boot

我正在创建一个具有Web,MySQL和JPA依赖关系的基本spring应用程序。我在服务器上设置了一个嵌入式数据库,并试图在我的spring应用程序中访问它。我已经在properties和application.yml文件中输入了所有正确的详细信息,但仍然收到错误消息。我收到的确切错误是:

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"

任何帮助将不胜感激。

application-dev.yml

spring:

  profiles: dev

  thymeleaf:
    # do not cache -> hot reload of templates
    cache: false

  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/bookerdb
    username: booker
    password: ${db_password}
  jpa:
    hibernate:
      connection:
        charset: utf8
        useUnicode: true
      ddl-auto: update
    naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
    properties.hibernate.dialect: org.hibernate.dialect.PostgreSQL94Dialect

application.properties :(密码已编辑)

initial_admin_password=test
db_password=test
profile=dev

一些相关的依赖项:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.5.6-Final</version>
    </dependency>
</dependencies>

0 个答案:

没有答案