我正在尝试在具有多个数据库的复杂ERP上使用flyway,但我没有找到任何使其运行的提示。 我正在和Hudson一起使用ant脚本来构建整个系统。 因此,我创建了一个包含以下内容的migrate.xml文件,并在下面的任务中多次调用该脚本。 但是,该任务仅运行一次任何错误。 如果我将任务调用两次,则会抛出异常。 有什么想法来解决这个问题吗?
提前致谢。
--exception
BUILD FAILED
/home/raphael/Development/ufpb/sig/sig-migration-fly-way/build.xml:6: The following error occurred while executing this line:
/home/raphael/Development/ufpb/sig/sig-migration-fly-way/migrate.xml:27: Flyway Error: java.lang.IllegalArgumentException: null source
at java.util.EventObject.<init>(EventObject.java:38)
at org.apache.tools.ant.BuildEvent.<init>(BuildEvent.java:93)
at org.apache.tools.ant.Project.fireMessageLogged(Project.java:2351)
at org.apache.tools.ant.Project.log(Project.java:492)
at com.googlecode.flyway.ant.AntLog.debug(AntLog.java:42)
at com.googlecode.flyway.core.dbsupport.DbSupportFactory.createDbSupport(DbSupportFactory.java:59)
at com.googlecode.flyway.core.Flyway.execute(Flyway.java:1159)
at com.googlecode.flyway.core.Flyway.info(Flyway.java:967)
at com.googlecode.flyway.ant.MigrateTask.doExecuteWithMigrationConfig(MigrateTask.java:157)
at com.googlecode.flyway.ant.AbstractMigrationLoadingTask.doExecute(AbstractMigrationLoadingTask.java:271)
at com.googlecode.flyway.ant.AbstractFlywayTask.execute(AbstractFlywayTask.java:329)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
--task
<target name="test">
<ant antfile="migrate.xml">
<property name="dir" value="sigaa"/>
<property name="database" value="demo_development"/>
</ant>
</target>
---migrate.xml
<?xml version="1.0"?>
<project name="migrations" default="deploy" basedir="." xmlns:flyway="antlib:com.googlecode.flyway.ant">
<path id="flyway.classpath">
<!-- include all jars containing jdbc drivers -->
<!-- include all jars and directories containing sql migrations -->
<!-- include all jars and directories containing compiled java migrations -->
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef uri="antlib:com.googlecode.flyway.ant"
resource="com/googlecode/flyway/ant/antlib.xml" />
<property name="flyway.driver" value="org.postgresql.Driver"/>
<property name="flyway.initOnMigrate" value="true"/>
<property name="flyway.validateOnMigrate" value="true"/>
<property name="flyway.url" value="jdbc:postgresql://localhost:5432/${database}"/>
<property name="flyway.user" value="***"/>
<property name="flyway.password" value="****"/>
<property name="flyway.table" value="schema_version_${dir}"/>
<property name="flyway.locations" value="filesystem:db/migrations/${dir}"/>
<target name="migrate">
<flyway:migrate />
</target>
<target name="deploy" depends="migrate">
<flyway:info />
</target>
</project>
答案 0 :(得分:1)
问题出在flyway-ant项目的com.googlecode.flyway.ant.AntLog类中,因为org.apache.tools.ant.Project类的log方法。在第二次执行时,代码antProject.getThreadTask(Thread.currentThread())返回null并发生错误。 我提出了一个if语句来解决问题,如下面的代码
if (task != null)
antProject.log(task, message, null, Project.MSG_VERBOSE);
else
antProject.log(message, null, Project.MSG_VERBOSE);