`
a_lgz
  • 浏览: 2039 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

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层注入进来。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics