当前位置: 首页 > 知识库问答 >
问题:

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

施琦
2023-03-14

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

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

changelog主文件名为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>
<?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>

我是不是漏掉了什么?根据我的了解,application.properties上的属性是所需要的,并且在您的changelog文件中通过${propertyName}使用它。

共有1个答案

阎星华
2023-03-14

我在一段时间内发现了这一点...就我的mystake我使用了LiquiBase.Parameters.Schema而不是Spring.LiquiBase.Parameters.Schema。

 类似资料:
  • 尝试为Spring Boot创建一个最初如下所示的小型自定义gradle任务: 任务应该如下所示: 我尝试了这个,但它不工作: 如何将此调试标志传递给 bootRun 任务?

  • 我读了很多关于如何在spring boot项目中使用spring-boot-starter-parent的帖子。基本上,我读过一些帖子(Spring文档也讨论了这一点),这些帖子描述了两种实现这一点的方法 直接使用spring-boot-starter-parent作为项目父级。它给我们带来了依赖管理和插件管理的好处。 另一种方法是在项目pom中导入spring-boot-starter父级(如果

  • 我想验证我的控制器中的一个请求参数。请求参数应该来自给定值列表中的一个,如果不是,则应该抛出错误。在下面的代码中,我希望请求参数orderBy来自@Values准许中存在的值列表。 我已经编写了一个自定义bean验证器,但不知何故,它不起作用。即使我为查询参数传递任何随机值,也不会验证并引发错误。

  • 我正在寻找Spring Boot maven应用程序的工作示例,没有引用spring-boot-starter-parent作为父POM。 我在Spring Boot docs-http://Docs.Spring.io/spring-boot/Docs/1.0.1.release/reference/htmlsingle/#using-boot-maven-your-own-parent中找到了

  • 我已经用自定义注释注释了Spring bean,但似乎Spring在创建bean后删除了我的自定义注释。 第二步不行,我的自定义注释丢失了。(可能是到期的代理文件) 我的豆子 我的一个自定义注释的示例 findAndDoStuffWithAnnotatedThings Bean中出错的内容被传递到一个类,在该类中,我的自定义注释得到验证,但我的验证程序找不到任何注释。(Util使用isAnnota

  • ...创建存储库bean时出错... noClassDefoundError:com/mysql/jdbc/socketFactory