运行应用程序时在Spring应用程序中获取错误

时间:2017-11-08 13:25:27

标签: spring

  

错误消息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'financialYearController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cerp.accounting.service.FinancialYearService com.cerp.accounting.controller.FinancialYearController.financialYear; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'financialYear': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cerp.accounting.dao.FinancialYearDao com.cerp.accounting.serviceImpl.FinancialYearServiceImpl.financeyeardao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'financeyeardao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.cerp.accounting.DaoImpl.FinancialYearDaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

1 个答案:

答案 0 :(得分:0)

您将答案发布到您自己的“问题”

'没有为依赖项找到类型[org.hibernate.SessionFactory]的限定bean:预计至少有一个bean可以作为此依赖项的autowire候选者。'

尝试将SessionFactory提供为Spring bean。

@Bean
public SessionFactory sessionFactory(HibernateEntityManagerFactory hemf){
    return hemf.getSessionFactory();
}
相关问题