javaconfig配置的sessionFactory在DAO层怎么注入进来

@Configuration
public class AppConfig {
    @Bean
    public SessionFactory sessionFactory() throws Exception{
        AnnotationSessionFactoryBean factory =new AnnotationSessionFactoryBean();
        factory.setDataSource(dataSource());//设置数据据
        factory.setPackagesToScan(new String[]{"algz.platform"});
factory.afterPropertiesSet();
        return factory.getObject();
    }

DAO:

@Repository("SQLiteDao")
public class SQLiteDaoImpl implements SQLiteDao {
    @Autowired
    private SessionFactory sessionFactory;
   

启动报错:
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), @org.springframework.beans.factory.annotation.Qualifier(value=sessionFactory)}


请问怎样在DAO层注入进来。

你可能感兴趣的:(spring)