• 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

  • 相关阅读:
    SGU 271 Book Pile (双端队列)
    POJ 3110 Jenny's First Exam (贪心)
    HDU 4310 Hero (贪心)
    ZOJ 2132 The Most Frequent Number (贪心)
    POJ 3388 Japanese Puzzle (二分)
    UVaLive 4628 Jack's socks (贪心)
    POJ 2433 Landscaping (贪心)
    CodeForces 946D Timetable (DP)
    Android Studio教程从入门到精通
    Android Tips – 填坑手册
  • 原文地址:https://www.cnblogs.com/yft-javaNotes/p/10348192.html
Copyright © 2020-2023  润新知