构建SpringBoot工程,其中构建了一个common公共项目包,其他项目包(如user包)的pom.xml中添加common包的依赖,在开发时,有时候需要在common包中使用自定义查下语句,需写自己的mapper.xml;
如果已经在user包中使用了UserMapper.xml,此时在common中又自定义了UserMapper.xml, 而user已经依赖了common包,就会造成UserMapper.xml重复导致错误;
解决方法:可以将common包中的UserMapper.xml重命名为CommonUserMapper.xml; 同时在user包中的application.properties文件中如此配置:mybatis.mapper-locations=classpath*:mapper/*.xml ----- classpath后面的* 不能省略,否则会报错。