tblank
tblank

Reputation: 257

Should I be able to use a Spring placeholder for Flyway bean's init-method?

Since we use different application.properties files for different builds and deployments (for instance for different types of developers and test environments, in addition to deploying to Prod), I'd like to be able to change which init-method is configured for the Flyway bean in Spring's application-context.xml. I'd like to do something like this:

<context:property-placeholder location="classpath:application.properties,classpath:application-instance.properties"/>
<bean id="flyway" class="org.flywaydb.core.Flyway" init-method="${flyway.database.init.method}">
    <property name="baselineOnMigrate" value="true" />
    <property name="locations" value="classpath:/db-migrations/sql/" />
    <property name="dataSource" ref="dataSource" />
</bean>    

But even though I'm using this application.properties file in other placeholders in the XML config, I get this error:

.BeanDefinitionValidationException: Couldn't find an init method named '${flyway.database.init.method}' on bean with name 'flyway'

Upvotes: 2

Views: 557

Answers (1)

leeor
leeor

Reputation: 17801

If you are using spring 3.1 or higher, I would strongly suggest you look at using environment profiles for this. They were specifically designed to solve this problem.

Check out this post for details.

Upvotes: 2

Related Questions