带有 spring-boot 的自定义 sql 中的 Liquibase 参数

Liquibase parameters in custom sql with spring-boot

我在 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:运行 启动 spring-boot 服务器时,liquibase sql 失败并出现以下错误: “$”或其附近的语法错误。

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

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

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