LiquiBase-将参数从命令行或属性传递到Changeset XML [英] LiquiBase - Passing Parameter From CommandLine Or Properties to Changeset XML

查看:76
本文介绍了LiquiBase-将参数从命令行或属性传递到Changeset XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将更新命令中的参数以及liquibase属性文件传递给我的变更集.由于某种原因,它无法将占位符识别为参数,但会将其解析为值.

I am trying to pass a parameter from my update command as well as the liquibase properties file to my changeset. For some reason, it does not recognise the placeholder as a parameter but parses it as a value.

这是我调用changeLog(成功运行)的方式:

This is how I invoke the changeLog (which runs successfully):

@echo off
call Liquibase --changeLogFile=myChangeLogFile.xml update -Dparamname=value

myChangeLogFile.xml:

myChangeLogFile.xml:

<changeSet author="tobi" id="preMigration" runAlways="true">
    <executeCommand executable="C:\myBatFile.bat">
        <arg value="${liquibase.properties.Dparamname}"/>
        <arg value="${liquibase.properties.url}"/>
    </executeCommand>  
</changeSet>

该脚本无法将$ {liquibase.properties.Dparamname}或$ {liquibase.properties.url}识别为占位符.

The script does not recognise ${liquibase.properties.Dparamname} or ${liquibase.properties.url} as placeholders.

我的Liquibase.properties文件具有

My Liquibase.properties file has the

url:jdbc:oracle:thin:@xyz:1521:ORCL 

参数集.

您知道如何访问属性或命令行参数吗?

Any idea how I can access the properties or the command line parameters?

谢谢

感谢您的反馈.

Tobias

推荐答案

而不是在变更日志中使用它:

Rather than using this in your changelog:

<changeSet author="tobi" id="preMigration" runAlways="true">
    <executeCommand executable="C:\myBatFile.bat">
        <arg value="${liquibase.properties.Dparamname}"/>
        <arg value="${liquibase.properties.url}"/>
    </executeCommand>  
</changeSet>

它应该看起来像这样:

<changeSet author="tobi" id="preMigration" runAlways="true">
    <executeCommand executable="C:\myBatFile.bat">
        <arg value="${paramname}"/>
        <arg value="${url}"/>
    </executeCommand>  
</changeSet>

命令行上的 -D 是用于设置系统属性的标准 java 机制,但是在访问它们时您只需使用属性名称.我相当确定您也不需要使用 liquibase.properties 前缀.

The -D on the command line is the standard java mechanism for setting system properties, but when accessing them you just use the property name. I am fairly certain that you don't need to use the liquibase.properties prefix either.

这篇关于LiquiBase-将参数从命令行或属性传递到Changeset XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆