我正在用spring和hibernate构建一个项目 sessionFactory
注入 setSessionFactory
,但是当我开始这个项目时,我得到了一个错误
道:
@Repository("osImageInfoDao")
public class OSImageInfoDao extends GenericDao<OSImageInfo, Integer> {
}
public class GenericDao<T, PK extends Serializable> {
protected SessionFactory sessionFactory;
@Autowired
public void setSessionFactory(final SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}
启动项目时,出现一个错误:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'imageDownloadService':
Unsatisfied dependency expressed through field 'imageInfoService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'osImageInfoService':
Unsatisfied dependency expressed through field 'imageInfoDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'osImageInfoDao':
Unsatisfied dependency expressed through method 'setSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.hibernate.SessionFactory' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} [AbstractApplicationContext.java:559]
暂无答案!
目前还没有任何答案,快来回答吧!