2012-04-24 107 views

回答

4

documentation描述了changeLogPropertyDefined前提条件。

下面的例子为我工作得很好:

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

    <changeSet author="mark (generated)" id="mark-1"> 
     <preConditions onFail="HALT"> 
      <changeLogPropertyDefined property="testing" value="1"/> 
     </preConditions> 

     <createTable tableName="TEST001"> 
      <column name="ID" type="VARCHAR(10)"> 
       <constraints nullable="false"/> 
      </column> 
      <column name="X" type="VARCHAR(9)"> 
       <constraints nullable="false"/> 
      </column> 
      <column name="Y" type="DECIMAL(7,2)"/> 
      <column name="Z" type="DECIMAL(7,2)"/> 
     </createTable> 
    </changeSet> 

</databaseChangeLog> 

我从Maven的运行liquibase。测试属性可以从命令行设置如下:

mvn -Dtesting=1 compile 
+0

哇,我必须是盲人,不知道我怎么会错过这个:)谢谢你的回答! – nansen 2012-04-24 20:20:31

+0

@nansen前提条件名称具有误导性。我必须测试它是否适用于普通的Java属性 – 2012-04-24 20:28:42

相关问题