代码改变世界
[登录 · 注册]
  • springboot2 中Druid和ibatis(baomidou) 遇到org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.iflytek.pandaai.service.multi.mapper.TanancyMapper
  • 调用mapper中任何方法都会出现类似的错误

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.iflytek.pandaai.service.multi.mapper.TanancyMapper.insert
    
    	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
    	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
    	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
    	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
    	at com.sun.proxy.$Proxy34.insert(Unknown Source)
    	at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.save(ServiceImpl.java:99)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    

      

    检查 是否是有申明 SqlSessionFactory的bean,例如:

    @Bean(name = "DruidsqlSessionFactory")
        @Primary
        public SqlSessionFactory getSessionFactory(DruidDataSource dataSource) throws Exception {
            SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
            factoryBean.setDataSource(dataSource);
            return factoryBean.getObject();
        }

    而该类和另外的SqlSessionFactory冲突,

    解决办法:

    1、在注解中申明要用的sqlSessionFactory bean名称

    @MapperScan(basePackages = {"com.iflytek.pandaai.service.**.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")

  • 上一篇:Spring的工具类StringUtils使用
    下一篇:gradle 多模块Springboot项目 compile project引用其他模块的坑
  • 【推广】 阿里云小站-上云优惠聚集地(新老客户同享)更有每天限时秒杀!
    【推广】 云服务器低至0.95折 1核2G ECS云服务器8.1元/月
    【推广】 阿里云老用户升级四重礼遇享6.5折限时折扣!
  • 原文:https://www.cnblogs.com/jifeng/p/11823239.html
走看看 - 开发者的网上家园