Closed
Description
Martin Wegner opened SPR-12744 and commented
Since Spring 4.1.5 the DI cannot find my profile activated 'database.dataSource' bean.
My web.xml activates the 'jetty' profile:
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>jetty</param-value>
</context-param>
And my config looks like:
@Profile("live")
@Bean(name = "database.dataSource")
public DataSource jndiDataSource() {
...
}
@Profile("!live")
@Bean(name = "database.dataSource")
public DataSource jdbcDataSource() {
...
}
@DependsOn({"database.dataSource", "databaseForUnitTestFramework"})
@Bean(name = "sessionFactory")
public LocalSessionFactoryBean localSessionFactoryBean() {
...
}
The '!live' annotated bean must be activated and used.
With Spring 4.1.4 and lower it works.
It is a blocker bug because the whole application does not start.
Affects: 4.1.5
Issue Links:
- Conditions on an overriding bean method effectively get ignored [SPR-12694] #17292 Conditions on an overriding bean method effectively get ignored
- Doc: Consistent @Profile declarations on overloaded @Bean methods [SPR-15266] #19831 Doc: Consistent
@Profile
declarations on overloaded@Bean
methods