在Spring-framework下打破@Resource注入> 4.1.0

时间:2014-12-01 18:09:10

标签: spring spring-annotations

@Resource注入似乎在spring-framework 4.1.0和4.1.1之间表现不同,因为它认为从抽象类扩展的类中的方法是桥,它从不调用setter。

例如

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

@Component
public final class RealComponent extends AbstractComponent {
}

如果我将@Resource更改为@Autowired,那么它会按预期工作。

我认为打破这种情况的改变是

https://github.com/spring-projects/spring-framework/commit/f4219ca06bbd1c324567ab9e74d0d18693359810#diff-2

解决SPR-12187

我提供了一个完整的spring-boot项目,用于演示

中的问题

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

0 个答案:

没有答案