zoukankan      html  css  js  c++  java
  • springboot+mabatis-puls 整合问题 Invalid bound statement

    mybatis  Invalid bound statement (not found)   xml文件接口可用,但是baseMapper方法不可用。

    原因 : spring boot+mybatis-plus 框架搭建使用双数据源时,在datasource里面规定了自己的  sqlSessionFactory 。mybatis-plus 应该用  

    MybatisSqlSessionFactoryBean 
    改造前:
        @Bean(name = "masterSqlSessionFactory")
        @Primary
        public SqlSessionFactory sqlSessionFactory(@Qualifier("masterDataSource") DataSource dataSource) throws Exception {
            SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
            bean.setDataSource(dataSource);
            bean.setMapperLocations(
                    new PathMatchingResourcePatternResolver().getResources("classpath*:/mapper/master/*Mapper.xml"));
            return bean.getObject();
        }

    改造后:

        @Bean(name = "masterSqlSessionFactory")
        @Primary
        public MybatisSqlSessionFactoryBean sqlSessionFactory(@Qualifier("masterDataSource") DataSource dataSource) throws Exception {
            MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
            bean.setDataSource(dataSource);
            bean.setMapperLocations(
                    new PathMatchingResourcePatternResolver().getResources("classpath*:/mapper/master/*Mapper.xml"));
            return bean;
        }

     具体配置可以参考 https://dadadajiong.coding.net/public/springboot-framework/springboot-mabatisplus-datasource/git/files

    MasterDataSourceConfig

    框架整合参考网络大神。



    -- 沉着,冷静,bug总会解决,未来道路很光明。
  • 相关阅读:
    爱摘苹果的小明
    盗梦空间
    九九乘法表
    谁是最好的Coder
    画图
    黑色帽子
    a letter and a number
    运维开发面试题
    python 守护进程daemon
    kubernets 应用部署
  • 原文地址:https://www.cnblogs.com/dadadajiong/p/14441105.html
Copyright © 2011-2022 走看看