配置数据源失败:’url’ 属性 – 尽管已指定

huangapple 未分类评论42阅读模式
英文:

Failed to configure a DataSource: 'url' attribute - although specified

问题

我试图使用 application.yml 而不是 application.properties 来运行应用程序,但是失败了。请帮忙。相同的配置在 application.properties 中是可以工作的。

我的 application.yml 配置如下:

spring:
    profiles: container
    jpa:
        show-sql: true
        database: MYSQL
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
        hibernate:
            ddl-auto: update
    datasource:
        url: jdbc:mysql://mysql57:3308/hello_java
        username: demo_java
        password: 1234
        driver-class-name: com.mysql.jdbc.Driver

启动应用程序时出现错误。若要显示条件报告,请使用启用了 'debug' 的模式重新运行应用程序。
2020-04-03 10:40:26.671 ERROR 12600 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


应用程序启动失败


描述:

配置数据源失败:未指定 'url' 属性,并且无法配置嵌入式数据源。

原因:无法确定适合的驱动程序类

操作:

请考虑以下内容:

  • 如果您想要使用嵌入式数据库(如 H2、HSQL 或 Derby),请将其放置在类路径上。
  • 如果您有要从特定配置文件加载的数据库设置,您可能需要激活该配置文件(当前未激活任何配置文件)。

进程以退出码 1 结束

英文:

I am trying to get run application.yml instead of application.properties. But it fails. Please help. The same thing works in application.properties.

My application.yml looks like this:

spring:
    profiles: container
    jpa:
        show-sql: true
        database: MYSQL
        database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
        hibernate:
            ddl-auto: update
    datasource:
        url: jdbc:mysql://mysql57:3308/hello_java
        username: demo_java
        password: 1234
        driver-class-name: com.mysql.jdbc.Driver

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-04-03 10:40:26.671 ERROR 12600 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


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).

Process finished with exit code 1

huangapple
  • 本文由 发表于 2020年4月3日 23:51:27
  • 转载请务必保留本文链接:https://java.coder-hub.com/61015671.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定