英文:
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
专注分享java语言的经验与见解,让所有开发者获益!
评论