我正在尝试设置我的应用程序,以便当它部署在任何环境中时它会自动升级数据库,所以我在 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表,有什么想法吗?