我正在嘗試使用flyway test extension 1.7.0的佔位符。 我定義在flyway.properties的佔位符:Placeholder replacement not working with flyway test extensions
flyway.placeholders.schema_name=MYSCHEMA
我的SQL腳本,看起來像這樣:
create schema ${schema_name};
當運行飛路測試,我發現了以下錯誤:
117157 [main] DEBUG com.googlecode.flyway.core.migration.sql.SqlScript - Found statement at line 1: create schema ${schema_name};
117157 [main] DEBUG com.googlecode.flyway.core.migration.sql.SqlStatement - Executing SQL: create schema ${schema_name}
117157 [main] ERROR com.googlecode.flyway.core.migration.DbMigrator - com.googlecode.flyway.core.exception.FlywayException: Error executing statement at line 1: create schema ${schema_name}
117158 [main] ERROR com.googlecode.flyway.core.migration.DbMigrator - Caused by org.hsqldb.HsqlException: Unknown JDBC escape sequence: {: {schema_name}
117158 [main] DEBUG com.googlecode.flyway.core.migration.DbMigrator - Finished migrating to version 1.1 (execution time 00:00.005s)
所以它看起來像佔位符替換不起作用。 順便說一句,我的flyway.properties文件已成功加載(我也用它作爲jdbc url等其他值)。
有人知道這裏可能是什麼問題嗎?
EDIT1它看起來像Flyway類中的configure方法沒有被調用。我必須添加一些東西到應用程序上下文嗎?
EDIT2一個解決方案,我們發現是設置佔位符中的ApplicationContext:
<bean id="flyway" class="com.googlecode.flyway.core.Flyway"
depends-on="dataSourceRef">
<property name="dataSource" ref="dataSourceRef" />
<property name="placeholders" >
<map>
<entry key="schema_name" value="${flyway.placeholders.schema_name}" />
</map>
</property>
</bean>
但我們仍在尋找更好的解決辦法...