zoukankan      html  css  js  c++  java
  • mybatis-plus Invalid bound statement (not found) 问题

    自己搭一个项目,spring boot+mybatis-plus,引用mybatis-plus  执行发现自己写的sql可以执行,执行basemapper里的方法就会出错,

    mybatis-plus Invalid bound statement (not found) 

    检查文件(application.yml、mapper.xml等)配置,编译加载是否正确

    发现都没什么问题,包加载也替换了几个版本,还是不行,

    后面发现需要将mybatis的sqlSessionFactory替换成mybatis-plusd的MybatisSqlSessionFactoryBean

    因为是自己写的sqlSessionFactory加载一直也没注意到这个问题,使用默认配置应该也没有这个问题,记录下

      @Bean("sqlSessionFactory")
    @Primary
    public SqlSessionFactory sqlSessionFactory(@Autowired @Qualifier("dataSource") DataSource dataSource) throws Exception {

    MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource);
    sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));

    // Interceptor interceptor = new PageInterceptor();
    // Properties properties = new Properties();
    // properties.setProperty("helperDialect", "sqlserver");
    // properties.setProperty("offsetAsPageNum", "true");
    // properties.setProperty("rowBoundsWithCount", "true");
    // properties.setProperty("reasonable", "false");
    // interceptor.setProperties(properties);
    // sqlSessionFactoryBean.setPlugins(new Interceptor[] {interceptor});


    return sqlSessionFactoryBean.getObject();

    }
  • 相关阅读:
    Count the Buildings HDU
    Airport UVA
    17南宁网络赛
    git Please move or remove them before you can merge.
    php ajax bootstrap多文件上传图片预览,ajax上传文件
    thinkphp5多语言
    ueeditor 百度编译器使用onchange效果
    mysql sql_mode=only_full_group_by问题?
    mac navicate 2013
    mac Nginx+CI出现404错误
  • 原文地址:https://www.cnblogs.com/zhouyb/p/10469973.html
Copyright © 2011-2022 走看看