我使用的是 弹簧靴 与 液基,而我的数据库配置是设置在一个 application.properties
文件。
spring.datasource.url=jdbc:postgresql://localhost:5432/comptesfrance
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driver=org.postgresql.Driver
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisDialect
spring.liquibase.change-log=classpath:/db/changelog/compte-france-postgis-changelog.xml
在maven插件的帮助下 liquibase-core
和 liquibase-maven-plugin
一切都很好,我的数据库结构在项目生命周期内都能顺利更新。
然而,我最近在开发环境中犯了一个错误,我必须使用命令行来执行回滚。删除我刚刚创建的一个变更集。
我进入一个bash shell,并执行.NET命令。
mvn liquibase:rollback -Dliquibase.rollbackCount=1
但它失败了,消息是:"数据库URL既没有被指定为参数,也没有被指定在属性文件中。".
我可以在配置中设置一个:
<propertyFile>${project.build.directory}/classes/liquibase.properties</propertyFile>
的配置中设置一个:。liquibase-maven-plugin
插件,如果我有这样的文件... 但我的属性是在我的 application.properties
文件代替。
如果我试图提及这个 application.properties
归档 液基,有 <propertyFile>${project.basedir}/src/main/resources/application.properties</propertyFile>
配置。液基 不承认其条目。
[INFO] Parsing Liquibase Properties File
[INFO] File: /home/marc/dev/Java/comptes-france/metier-et-gestion/dev/DAOPostgis/../ApplicationMetierEtGestion/src/main/resources/application.properties
[INFO] 'spring.jpa.properties.hibernate.dialect' in properties file is not being used by this task.
[INFO] 'spring.datasource.url' in properties file is not being used by this task.
[INFO] 'spring.datasource.password' in properties file is not being used by this task.
[INFO] 'spring.datasource.username' in properties file is not being used by this task.
[INFO] 'spring.jpa.database-platform' in properties file is not being used by this task.
[INFO] 'spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation' in properties file is not being used by this task.
[INFO] 'spring.liquibase.change-log' in properties file is not being used by this task.
[INFO] 'spring.datasource.driver' in properties file is not being used by this task.
是否有办法通过 spring-boot:run
命令来发布回滚?
这将允许 spring-boot
送去 液基 它已经知道和使用的配置。
spring.datasource...中的属性名 application.properties
和 liquidate.properties
您有三个选择
通过命令行参数给出数据库参数
mvn liquibase:rollback -Dliquibase.rollbackCount=1 -Dliquibase.url=jdbc:postgresql://localhost:5432/comptesfrance -Dliquibase.username
看到 回球 对于所有论点
如果你需要一个永久的解决方案,那么你可以在你的液化基地属性中添加到你的。application.properties
并在同一个文件中重复使用它们,即
liquibase.url=jdbc:postgresql://localhost:5432/comptesfrance
spring.datasource.url=${liquibase.url}
(我没有测试过这个)