【问题标题】:liquibase initalization is executed in contradiction to the application.propertiesliquibase 初始化的执行与 application.properties 相矛盾
【发布时间】:2018-09-04 06:55:30
【问题描述】:

目前我有一个 SBA (Spring Boot App 1.5.10.RELEASE),它有两个配置属性文件,如 application-default.propertiesapplication-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


【解决方案1】:

Default properties for spring boot 1.5.10 是:

LIQUIBASE (LiquibaseProperties)

liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path.
liquibase.check-change-log-location=true # Check the change log location exists.
liquibase.contexts= # Comma-separated list of runtime contexts to use.
liquibase.default-schema= # Default database schema.
liquibase.drop-first=false # Drop the database schema first.
liquibase.enabled=true # Enable liquibase support.
liquibase.labels= # Comma-separated list of runtime labels to use.
liquibase.parameters.*= # Change log parameters.
liquibase.password= # Login password of the database to migrate.
liquibase.rollback-file= # File to which rollback SQL will be written when an update is performed.
liquibase.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used.
liquibase.user= # Login user of the database to migrate.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-03-31
    • 1970-01-01
    • 2011-05-02
    • 1970-01-01
    • 2021-04-13
    相关资源
    最近更新 更多