2017-02-21 76 views
0

我试图从我的更新命令以及liquibase属性文件传递参数到我的变更集。出于某种原因,它不会将占位符识别为参数,而是将其解析为一个值。LiquiBase - 从CommandLine或属性传递参数来更改XML

这是我如何调用更新日志(其中成功运行):

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

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}作为占位符。

我Liquibase.properties文件具有

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

参数集。

任何想法如何访问属性或命令行参数?

谢谢

我很感谢您的反馈。

托比亚斯

回答

0

,而不是你的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前缀。

+0

谢谢 $ {paramname}工作正常。不幸的是,我无法引用属性文件的参数。 –