【发布时间】:2018-09-04 06:55:30
【问题描述】:
目前我有一个 SBA (Spring Boot App 1.5.10.RELEASE),它有两个配置属性文件,如 application-default.properties 和 application-oracle.properties。此外,这些文件位于src/main/resources 中,它们最终会出现在BOOT-INF/classes/ 中的结果 jar 文件中
applilcation-oracle.properties 包含如下内容:
#
# Turn off liquibase initialization.
spring.liquibase.enabled=false
# Oracle settings
spring.datasource.url=jdbc:oracle:thin:@localhost:1521/xe
spring.datasource.username=..
spring.datasource.password=...
spring.datasource.driver-class-name=...
#
# Hibernate
spring.jpa.properties.hibernate.dialect=....
#
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
application-default.properties 看起来很相似,但 spring.liquibase.enabled 不包含它,它包含与本地 PostgreSQL 而不是 Oracle 的连接。
我的 pom 文件中依赖于 liquibase。
所以现在我想通过以下方式开始我的 SBA:
java -jar x.jar --spring.profiles.active=default ..
按预期打印出 liquibase 初始化正在运行.. 之后我想这样开始:
java -jar x.jar --spring.profiles.active=oracle ..
并预计不会根据给定的spring.liquibase.enabled=false 进行通过 liquibase 的初始化,但与我的预期相反,它将通过 liquibase 开始初始化。
所以问题是:我是否疏忽了什么?
【问题讨论】:
-
这取决于您使用的 spring 版本。看起来它在 2.0 中被重命名为“spring.liquibase.enables”以支持“liquibase.enabled”
-
Spring Boot 版本 1.5.10.RELEASE 当前。感谢您的提示。
-
那么它没有“spring”前缀:)
标签: spring-boot spring-profiles spring-boot-configuration