Skip to content

Regression in 4.1.5: Alternative @Bean declarations with same primary bean name do not work anymore [SPR-12744] #17341

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits ce085a6, bb5b5d5

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions