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;
    }

 

你可能感兴趣的:(springboot,mybatis,plus)