You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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.
This might be a "visibility bridge method" scenario since your base class isn't public... If you do declare it as public, @Resource might work fine as well?
In any case, there is an inconsistency in the bridge method handling code between @AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor; I'm going to fix this for 4.1.3.
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
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:
The text was updated successfully, but these errors were encountered: