Skip to content

Cannot use @Primary to override @ComponentScan-ed beans [SPR-10795] #15421

Closed
@spring-projects-issues

Description

@spring-projects-issues

Mike opened SPR-10795 and commented

A @Primary @Bean cannot override a @ComponentScan-ed @Component.

For example, if I have:

@Primary
@Bean
public Foo getFoo() {...}

and a scanned:

@Component
public class Foo {...}

... the @Component will always be @Autowired instead of the @Primary-annotated @Bean. Nothing in the documentation says that @Primary @Bean's should fail against @ComponentScan-ed ones.


Affects: 3.2.3

Reference URL: http://stackoverflow.com/questions/17945290/spring-primary-fails-against-componentscan

Issue Links:

4 votes, 8 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions