2

应用程序属性

TM_ESCALATION_QUALIFICATION=SHIFT_LEADER

应用程序.java

@Value( "${TM_ESCALATION_QUALIFICATION}" )
String escalationQualification;

@Bean
InitializingBean printConfigurations(DataSource datasource) {
    return () -> {
            Flyway flyway = new Flyway();
            flyway.setDataSource(datasource);
            flyway.getPlaceholders().put( "ESCALATION_QUALIFICATION", escalationQualification );    
            flyway.migrate();
    };
}

SQL 文件

insert into tm_qualification (ID, NAME, DELETABLE) values (sys_guid(), ${ESCALATION_QUALIFICATION}, 0); 

当我使用具有默认扩展名的文件时,上面的工作正常,但是当我将文件作为.sql扩展名时出现以下错误。

错误

org.flywaydb.core.api.FlywayException: No value provided for placeholder expressions: ${ESCALATION_QUALIFICATION}.  Check your configuration!
    at org.flywaydb.core.internal.util.PlaceholderReplacer.checkForUnmatchedPlaceholderExpression(PlaceholderReplacer.java:101)
    at org.flywaydb.core.internal.util.PlaceholderReplacer.replacePlaceholders(PlaceholderReplacer.java:78)
    at org.flywaydb.core.internal.dbsupport.SqlScript.<init>(SqlScript.java:79)....
4

1 回答 1

3

来自网络,建议使用

flyway.placeholderReplacement=false

仅在升级到> flyway 4.0.3后才有效(spring boot最新使用ooold版本)

另一件有效的事情是使用虚假的占位符前缀,这就是诀窍......

flyway.placeholderPrefix=$$$-bogus-$$$

于 2017-02-21T13:23:17.483 回答