Skip to content

@Resource injection broken under spring-framework > 4.1.0 [SPR-12490] #17096

@spring-projects-issues

Description

@spring-projects-issues

Doug Davies opened SPR-12490 and commented

@Resource injection seems to behave differently between spring-framework 4.1.0 and 4.1.1 because it thinks a method in a class extended from an abstract class is a bridge and it never calls the setter.

For example

abstract class AbstractComponent {
    @Resource
    public void setHttpServletRequest(final HttpServletRequest request) {
        System.out.println("Setting HttpServletRequest");
    }
}

@Component
public final class RealComponent extends AbstractComponent {
}

If I change the @Resource to @Autowired then it works as expected.

I think the change that broke this is

f4219ca#diff-2

It was to resolve #16801

I have provided a complete spring-boot project that demonstrates the issue at

https://github.com/funkyvisions/spring-boot-hello-world


Affects: 4.1.1, 4.1.2

Reference URL: http://stackoverflow.com/questions/27234508/resource-injection-broken-under-spring-framework-4-1-0

Issue Links:

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