最近用到了Spring2.5的注解,一般情况下是需要注入接口才可是使用,当没有接口,而直接在Action中注入Service层的实现类的时候,在运行会报
org.springframework.beans.factory.beannotofrequiredtypeexception bean named
这样的异常。如何不使用接口直接注入实现类呢?
1. 在spring配置文件中找到
<tx:annotation-driven transaction-manager="transactionManager" />
添加一个属性 proxy-target-class="true"
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
2. 下载cglib-nodep-2.2.jar添加到项目lib包中
@Resource(name = "articleServiceImpl")
private ArticleServiceImpl articleService;//ArticleServiceImpl为实现类,不是接口
==================================The End================================