org.apache.ibatis.binding.BindingException【原因汇总】

项目是由maven进行管理,进行分模块开发的,但是项目合并时,一个模块依赖另外一个模块,当前模块用另一个模快的方法的时候抛出异常,org.apache.ibatis.binding.BindingException,阅资料发现,

1, m a v e n 在编译的时候,有可能是当前模块在spring-mybaits配置文件配置扫描xml包时,没有扫描到依赖模块的xml文件,所以maven在编译打包时无法将依赖的模块xml打包,所以在当前模去调用依赖模块方法 时抛出异常


解决方法:
1,在当前模块的spirng-mybatis配置文件中修改,主要是< property name='mapperLocation' value='classpath*:/mappings/**/*Mapper.xml'> 的部分要在扫描xml文件时,
配置通用的扫描,使可以扫描到依赖模块的xml文件
<!-- myBatis文件 -->

  
  
< bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        < property name="dataSource" ref="dataSource"/>
        < property name="configLocation" value="classpath:mybatis-config.xml"/>
        
      
      
        < property name="mapperLocations" value="classpath*:/mappings/**/*Mapper.xml"/>
        < property name="plugins">
            < array>
                < bean class="com.github.pagehelper.PageHelper">
                    < property name="properties">
                        < value>
                            d ialect= oracle
                            r e a s o n a b l e =t rue
                        
      
      
                    
      
      
                
      
      
            
      
      
        
      
      
    
      
      

解决方法:
2,如果项目在特殊情况下,无法使用方法一配置模块统一的xml扫描,只能在当前模块的pom.xml文件中添加如下内容在m a v e n打包的时候,扫描所有依赖模块的xml,启动时冲突解决:

< build>
        < finalName>com.hsnn.bid
        < resources>
            < resource>
                < directory>src/m ain/java
                < includes>
                    < include>**/*.xml
                
    
    
                < filtering>true
            
    
    
        
    
    
    
    
    

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值