zoukankan      html  css  js  c++  java
  • org.springframework.beans.factory.BeanCreationException...

    在启动工程的时候出现如下异常:

    org.springframework.beans.factory.BeanCreationException: 
      Error creating bean with name 'userServiceImpl': Injection of autowired dependencies failed;
      nested exception is org.springframework.beans.factory.BeanCreationException:
      Could not autowire field: private cn.itcast.bos.dao.IUserDao cn.itcast.bos.service.impl.UserServiceImpl.userDao;
      nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDaoImpl'
      defined in URL [jar:file:/D:/Maven/repository/cn/itcast/bos-dao/1.0-SNAPSHOT/bos-dao-1.0-SNAPSHOT.jar!/cn/itcast/bos/dao/impl/UserDaoImpl.class]:
      Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

      项目中所有Dao实现类都继承了自定义的BaseDaoImpl,而BaseDaoImpl又继承了HibernateDaoSupport 
      以前写配置文件时,sessionFactory需要单独配置,现在全注解方式,如何设置sessionFactory呢? 
      在BaseDaoImpl中增加如下方法,使用Resource:

    //根据类型注入spring工厂中的会话工厂对象sessionFactory
    @Resource
    public void setMySessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }

      参考:https://bjyzxxds.iteye.com/blog/1163794

  • 相关阅读:
    面向对象知识点2
    面向对象知识点1
    面向对象知识点
    常用模块
    模块与包
    迭代器相关知识
    jquery.jqprint-0.3.js打印功能 以及页眉页脚设置显示与否
    js和layerjs配合实现的拖拽表格列
    iframe中跳转页面的区别
    select3搜索下拉树
  • 原文地址:https://www.cnblogs.com/yft-javaNotes/p/10348192.html
Copyright © 2011-2022 走看看