Skip to content

@Required doesn't play nice with @Configuration and @Bean [SPR-5744] #10414

@spring-projects-issues

Description

@spring-projects-issues

Kenny MacLeod opened SPR-5744 and commented

I've been using M3 to try porting fragments of existing applications to use @Configuration and @Bean instead of XML bean definitions. The bean classes make heavy use of @Required. When I try to configure one of these beans using annotations, and injecting collaborators java-style, the context fails to start up, saying that a @Required property has not been set.

This is a problem, because these existing application classes are used everywhere, mostly using the @Required annotation in conjunction with XML bean definitions. Also, the context:component-scan tag which is used to locate the @Configuration classes implicitly adds a RequiredAnnotationBeanPostProcessor to the context.

It's not clear how to handle this, unless the framework can automagically figure out that the @Bean method is injecting the collaborators.

I've created a standalone test case illustrating the problem.


Affects: 3.0 M3

Attachments:

Referenced from: commits c7b019c

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions