首页 > 编程语言 > 详细

@Repository 注解引发的异常: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field

时间:2017-08-07 20:24:27      阅读:6559      评论:0      收藏:0      [点我收藏+]

手头的项目使用spring mvc+ mybatis框架开发,今天调试时遇到奇怪的问题, biz层的ManagerImpl.java 一直报错:

   Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field。。。。

逐一检查了Dao层、biz层、service层的文件,没有发现异常, 经过各种check,终于发现原来是没有MapperImpl文件中没有加@Repository ,因此一直提示找不到对应的bean。至此问题解决。 

  @Repository注解用于将数据访问层 (DAO 层 ) 的类标识为 Spring Bean,代码如下:

        

@Repository
public class UserMapperImpl extends RecAbstractBaseWithBLOBsDAO<User,UserCriteria,UserMapper> implements UserMapper {

 同时在xml文件中启动dao扫描功能,配置代码如下:

 

<context:component-scan base-package="com.search.test" />
    <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->

  

  

 

  

 

  

@Repository 注解引发的异常: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field

原文:http://www.cnblogs.com/jinghan/p/7300923.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!