Java Spring boot忽略application.yml中的数据源url
我发现SpringBoot会自动忽略通过Java Spring boot忽略application.yml中的数据源url,java,spring,spring-boot,Java,Spring,Spring Boot,我发现SpringBoot会自动忽略通过org.springframework.boot.autoconfigure.jdbc.DataSourceProperties加载的所有数据源属性 我的应用程序.yml包含: spring: datasource: name: this is not ignored url: this is ignored 在启动期间,我看到一行: o.s.j.d.e.EmbeddedDatabaseFactory
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
加载的所有数据源属性
我的应用程序.yml
包含:
spring:
datasource:
name: this is not ignored
url: this is ignored
在启动期间,我看到一行:
o.s.j.d.e.EmbeddedDatabaseFactory : Creating embedded database 'this is not ignored'
调试显示,DataSourceProperties
对象在调用getUrl
期间未设置任何属性(调试还显示引发异常,但由于异常在日志中不可见,因此被静默忽略)
Url显然无效,但数据库已初始化
在1.2.7版本上测试
什么会导致这种奇怪的行为?如何进一步调试它?添加
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
org.apache.tomcat
TomcatJDBC
要解决这个问题
问题是由Spring Boot自动配置魔法造成的-我没有使用正确的Spring Boot starter。昨天刚对1.3.0.M5做了同样的操作,它工作了。您可能想试试1.2.6或M5。要查看哪些配置文件被读取,哪些不是,您可能需要安装执行器并查看/env端点。并尝试将
名称
排除在游戏之外。