Skip to content

Regression: @Primary annotation not working when overriding bean definition with classpath scanning [SPR-12934] #17527

@spring-projects-issues

Description

@spring-projects-issues

Daniel Hiller opened SPR-12934 and commented

The \@Primary annotation seemed to stop working as expected since Spring 4.1.0.RELEASE (including 4.1.6.RELEASE) as demonstrated in this stripped down github repo.

In the repository mentioned we created a stripped down version of our situation to demonstrate the problem. To get a quick start please have a look at the Application classes.

Run

mvn clean install && cd overridden-bean && mvn exec:java

for a demonstration. An execption should state that another bean type was expected.

NB: This looks like a regression as this is still working with latest Spring 4.0.9.RELEASE. Change the spring version in parent pom to 4.0.9.RELEASE, run the above command and see that it works as expected.

Versions used:

  • Apache Maven 3.2.3
  • Java 1.8.0_45
  • Ubuntu 14.04 LTS

Interestingly, when trying to convert this into spring unit tests (see branch convert-to-unit-tests) and then running the tests from either Intellij vs. maven I get a non deterministic behavior (i.e. running from Intellij fails the test, while mvn clean install does not fail the tests)


Affects: 4.1 GA, 4.1.6

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions