日常bug:maven项目部署服务器,mybatis 中mapper文件读取不到公司内部jar包的问题
昨天本地跑项目没问题,当部署到开发测试环境的时候出现mybatis中mapper.xml文件读取不到内部jar包,报错如下:
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.xxx'
Caused by: java.lang.ClassNotFoundException: Cannot find class: com.xxx
尝试找了网上说的方法:
1.网上说的VFS,在sqlSessionBean创建的时候加上一句:VFS.addImplClass(SpringBootVFS.class);
(io.terminus.boot.mybatis.autoconfigure.SpringBootVFS.class);
原因是:org.apache.ibatis.io.VFS实现无法扫描到第三方jar包中的类别名
结果:没有解决问题
后来跟公司的技术大佬讨论了一下,技术老大给出一个建议,后来成功解决。
方法:
在pom.xml文件maven插件下面加上
<includeSystemScope>true</includeSystemScope>
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin>