我使用Liquibase的2.0.5版本來測試數據庫遷移。目前,如果我定義了changeLogFile
屬性爲updateDatabase
任務,<updateDatabase changeLogFile="${changeLogFile}"
和"${changeLogFile}"
在liquibase.properties
指定爲changeLogFile=com/db/master.changelog.xml
,文件master.changelog.xml
將不被發現。Liquibase作爲一項螞蟻任務:找不到changelogs.xml的相對路徑
我使用Eclispe和ant standalone開始了一個ant任務。
所以我用下面的修復與${basedir}/**src**/
:
<updateDatabase changeLogFile="${basedir}/src/${changeLogFile}"
但我會沒有這樣一個骯髒的解決方案非常高興。
我嘗試指定XML文件中的類路徑,使用/箱目錄
<fileset dir="bin"> <include name="**/*.xml" /> </fileset>
但很多例外的發生,所以我評論了該塊。
我做錯了什麼?
的liquibase.properties
文件包含:
changeLogFile=com/db/master.changelog.xml
driver=org.h2.Driver
url=jdbc:h2:tcp://localhost/testhiberliq
username=sa
password=
#for diff between two databases
baseUrl=jdbc:h2:tcp://localhost/testhiberliq
baseUsername=sa
basePassword=
dropFirst=false
tag=version 1.4
outputFile=outputFile.xml
outputDiffFile=outputFile.txt
NewFile1.xml
的(用作build.xml
):
<?xml version="1.0" encoding="UTF-8"?>
<project name="liquibase-sample">
<property file="liquibase.properties" />
<path id="lib.path">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
<!-- <fileset dir="bin">
<include name="**/*.xml" />
</fileset> -->
</path>
<taskdef resource="liquibasetasks.properties">
<classpath refid="lib.path" />
</taskdef>
<target name="update-database">
<!-- <taskdef name="updateDatabase"
classpathref="lib.path" />-->
<updateDatabase changeLogFile="${basedir}/src/${changeLogFile}" driver="${driver}" url="${url}" username="${username}" password="${password}" dropFirst="${dropfirst}" classpathref="lib.path" />
</target>
</project>
master.changelog.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<include file="changelog/included.changelog.xml" relativeToChangelogFile="true"/>
<include file="changelog/included2.changelog.xml" relativeToChangelogFile="true"/>
<include file="changelog/included3.changelog.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
而且目錄樹:
I:.
│ .classpath
│ .project
│ liquibase.properties
│ NewFile.xml
│ NewFile1.xml
│ outputFile.txt
│ outputFile.xml
│
├───.settings
│ org.eclipse.jdt.core.prefs
│
├───bin
│ │ hibernate.cfg.xml
│ │
│ ├───com
│ │ └───db
│ │ │ master.changelog.xml
│ │ │
│ │ └───changelog
│ │ included.changelog.xml
│ │ included2.changelog.xml
│ │ included3.changelog.xml
│ │
│ └───testproject
│ │ Main.class
│ │
│ └───database
│ │ DatabaseDAO.class
│ │
│ └───pojo
│ Users.class
│
├───lib
│ h2-1.3.168.jar
│ liquibase.jar
│
└───src
│ hibernate.cfg.xml
│
├───com
│ └───db
│ │ master.changelog.xml
│ │
│ └───changelog
│ included.changelog.xml
│ included2.changelog.xml
│ included3.changelog.xml
│
└───testproject
│ Main.java
│
└───database
│ DatabaseDAO.java
│
└───pojo
Users.java
嗨馬克奧康納,我只有xml,放在類路徑中,沒有與更改日誌xml exisit罐。如果我嘗試設置「java」類路徑(又名「bin」),那麼會引發很多異常:無法從i中獲取資源:\ workspace \ TestLqbsProject \ bin \ com \ db \ changelog \ included.changelog .xml: java.util.zip。ZipException:打開zip文件時出錯 – 2013-05-06 13:14:17
嗨,馬克奧康再次:-)如果我使用 -tag檢索changelog-xmls的類路徑,則會發生異常。我現在使用位置「bin」的pathelement,所以liquibase螞蟻任務運行!其他更改不需要。非常感謝您的重播 –
2013-05-06 13:30:17