2017-04-07 55 views
0

我想在我的Ant項目中使用Flyway運行DDL腳本。我設法配置了類路徑,以便Flyway能夠看到遷移腳本。當我跑飛路:遷移任務,我得到這個異常:Flyway Ant嘗試打開.sql文件作爲zip,失敗並出現ZipException

Unable to obtain resource from (...)/src/ddl/V1__create_tables_logging.sql: java.util.zip.ZipException: error in opening zip file 
[flyway:migrate] Unable to obtain resource from (...)/src/ddl/V1__create_tables_logging.sql: 
[flyway:migrate] java.util.zip.ZipException: error in opening zip file 

有在最後一個建議:

[flyway:migrate] Possible solution: run the Ant javac and copy tasks first so Flyway can find the migrations 

但我的項目不是一個Java應用程序,我沒有任何Java源代碼用javac編譯。 Flyway是否需要將遷移腳本包裝在jar中?難道它只是用SQL語句運行一些文本文件嗎?

回答

0

不幸的是,你沒有提供你有的配置,沒有它很難說,究竟是什麼原因導致了這個問題。

但是我覺得很奇怪,你沒有使用location屬性的任務,而是classpath。嘗試使用您的遷移腳本指定目錄,如下所示:

<flyway:migrate> 
    <locations> 
     <location path="path/to/migrations"/> 
    </locations> 
    ... 
</flyway:migrate> 
+0

該文檔具有誤導性,它表示遷移應該在類路徑中,但只有在您事先將它們編譯爲jars時纔有效。作爲我的工作是使用flyway.locations屬性,並在文件顯示的示例之一中預先加上「filesystem:」路徑。 – lukfi

相關問題