【问题标题】:Liquibase parameters in custom sql with spring-boot带有spring-boot的自定义sql中的Liquibase参数
【发布时间】:2019-04-19 10:16:51
【问题描述】:

我在 jdk 11 上有一个 spring-boot 应用程序,使用 maven,具有以下 liquibase 依赖项:

   <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>3.6.2</version>
        </dependency>

更改日志主文件名为 db.changelog.xml ,位于 PROIECTTEST\src\main\resources\db 下,在 application.properties 上具有以下配置:

spring.liquibase.change-log=classpath:/db/db.changelog.xml
spring.liquibase.default-schema=public
liquibase.parameters.schema=public

看起来像:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">

    <include relativeToChangelogFile="true" file="changelog/initial/test.xml"/>     
</databaseChangeLog>

我的变更集 test.xml 文件位于 PROIECTTEST\src\main\resources\db\changelog\initial 看起来像:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
    <changeSet author="test" id="1540963204914-19">
    <sql > 
    select * from ${schema}.test
    </sql>

    </changeSet>

</databaseChangeLog>

当我使用命令 mvn spring-boot:run 启动 spring-boot 服务器时,liquibase sql 失败并出现以下错误: "$" 处或附近的语法错误。

我错过了什么吗?从我读到的 application.properties 上的属性是所需要的,并在您的更改日志文件中由 ${propertyName} 使用它。

【问题讨论】:

    标签: maven spring-boot liquibase


    【解决方案1】:

    我在一段时间内发现了它...,只是我的疑惑,我使用了 liquibase.parameters.schema 而不是 spring.liquibase.parameters.schema。

    【讨论】:

      【解决方案2】:

      这可能是因为public 是 liquibase 中的关键字。尝试使用一些不同的名称而不是 public。

      【讨论】:

      • 谢谢你的回答,我试过了,但不是那个问题:(
      猜你喜欢
      • 1970-01-01
      • 2016-06-21
      • 2014-09-03
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多