在JBoss 7上运行Flyway时出错

时间:2012-07-12 08:56:53

标签: java jboss flyway

我正在尝试设置我的应用程序,以便在部署到任何环境时自动升级数据库,因此我将以下内容添加到Spring配置中:

<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url"    value="jdbc:oracle:thin:@${db.host}:${db.port}:${db.database}" />
    <property name="username" value="${db.username}" />
    <property name="password" value="${db.password}" />
    <property name="maxActive" value="4" />
    <property name="maxWait" value="5000" />
    <property name="defaultAutoCommit" value="false" />
    <property name="defaultReadOnly" value="false" />
    <property name="validationQuery" value="select '1' from DUAL" />
</bean>
<!-- ADDED IN AN ATTEMPT TO FIX THE PROBLEM -->
<bean id="flyway-init" class="com.googlecode.flyway.core.Flyway" init-method="init">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate" depends-on="flyway-init">
    <property name="dataSource" ref="datasource"/>
</bean>

但是当我在JBoss 7中运行它时,我收到以下错误:

com.googlecode.flyway.core.validation.ValidationException: Found non-empty schema 'WMYERS' without metadata table! Use init() first to initialize the metadata table.

我已经针对数据库运行了一个flyway clean-migrate,所以它已经设置好并且准备好了,并且SCHEMA_HISTORY表存在,有什么想法吗?

1 个答案:

答案 0 :(得分:0)

Flyway默认检查是否已正确初始化非空架构。此检查可确保在配置错误的情况下,Flyway不会迁移或清除错误的数据库。迁移失败并抛出此异常,因为具有已定义名称的元数据表应该存在,并且当您的db的模式具有某些数据时非元空。可能手动修改了元数据表。