项目是由maven进行管理,进行分模块开发的,但是项目合并时,一个模块依赖另外一个模块,当前模块用另一个模快的方法的时候抛出异常,org.apache.ibatis.binding.BindingException,阅资料发现, 1, m a v e n 在编译的时候,有可能是当前模块在spring-mybaits配置文件配置扫描xml包时,没有扫描到依赖模块的xml文件,所以maven在编译打包时无法将依赖的模块xml打包,所以在当前模去调用依赖模块方法 时抛出异常

项目是由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
                         value>
                     property>
                 bean>
             array>
         property>
     bean>

解决方法:
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
                 includes>
                < filtering>true
             resource>
         resources>
     build>

猜你喜欢

转载自blog.csdn.net/qq_34125349/article/details/78220524
今日推荐