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

  • 相关阅读:
    javascript对话框
    重构之美-走在Web标准化设计的路上[复杂表单]
    xhtml标准下的height:100%
    javascript简洁的LightBox
    Web标准学习书籍推荐
    Email
    jQuery插件Cookie
    Linq to sql 简单性能差异指引 2 (转)
    jQuery Impromptu
    UI
  • 原文地址:https://www.cnblogs.com/yft-javaNotes/p/10348192.html
Copyright © 2011-2022 走看看