mybaits plus Invalid bound statement (not found) 異常

錯誤說明:巨坑,集成阿里的druid後,因使用了 SqlSessionFactoryBean導致mybatis自帶的方法一直無法執行,報錯 Invalid bound statement (not found) 異常;

解決方法:根據官方提供的解決方案將 SqlSessionFactoryBean 改爲 MybatisSqlSessionFactoryBean 即可。

大功告成!!!代碼如下:

 @Bean
    public MybatisSqlSessionFactoryBean sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
//SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
        MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
        bean.setDataSource(dataSource);
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        bean.setMapperLocations(resolver.getResources("classpath:/com/aj/dao/*.*"));
        return bean;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章