zoukankan      html  css  js  c++  java
  • @Repository 注解引发的异常: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field

    手头的项目使用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的映射 -->
    

      

      

      

      

    
    
  • 相关阅读:
    Python格式化输出
    每天写点shell脚本 (持续更新)
    linux limits.conf 配置
    ELK 日志分析系统
    开源大数据处理工具
    glusterFS分布式存储部署流程
    glusterFS的部署流程
    parted命令详解
    /proc文件系统
    /proc文件系统(二):/proc/<pid>/stat
  • 原文地址:https://www.cnblogs.com/jinghan/p/7300923.html
Copyright © 2011-2022 走看看