maven重复引入jar包导致的一次问题

现象:

项目启动时不断刷这一行,启动失败。

2019-05-05 17:35:04 WARN org.springframework.beans.factory.support.DefaultListableBeanFactory:1490 - Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jyUserVipMapper' defined in URL [jar:file:/D:/xxx/xxx-xxx-api-copy/xxx-xxx-api-web/target/xxx-nmedia-api-web/WEB-INF/lib/xxx-nmedia-api-dal-1.2.2.jar!/com/xxx/nmedia/api/dal/dao/vip/JyUserVipMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [xxx-nmedia-api-dal.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/D:/xxx/xxx-nmedia-api-copy/xxx-nmedia-api-web/target/xxx-nmedia-api-web/WEB-INF/lib/xxx-core-dal-1.5.2-SNAPSHOT.jar!/mapper/AgentTemplateMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.xxx.jybook.core.dal.dao.AgentTemplateMapper.BaseResultMap; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [xxx-nmedia-api-dal.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/D:/xxx/xxx-nmedia-api-copy/xxx-nmedia-api-web/target/xxx-nmedia-api-web/WEB-INF/lib/xxx-core-dal-1.5.2-SNAPSHOT.jar!/mapper/AgentTemplateMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.xxx.xxx.core.dal.dao.AgentTemplateMapper.BaseResultMap

解决过程:

1.初步怀疑idea抽风,重启项目,重启idea,重启电脑,全部无效。

2.开始百度这堆东西,网上的说法是mapper文件中有相同名字的结果集,搜了下报错的这个jar‘xxx-core-dal-1.5.2-SNAPSHOT.jar’,并没有这样的错误。

3.只能开始分析错误,提示已经包含相同的BaseResultMap?double shift了一下‘AgentTemplateMapper’类,idea弹出来两个文件,分别将两个类打开,发现分属于不同版本的jar包。锁定元凶——maven重复加载依赖。在类中右键拷贝reference,获取本地仓库的jar位置,清除目录。

4.刷新maven,jar包波浪线爆红。上网百度了下,原来是idea默认勾了work offline。取消勾选,重刷成功。

5.启动成功!

--------------------------------------------------第二次遇到该问题------------------------------------------------

这次jar包只加载了一次。

看报错是target文件重复加载。

maven clean compile package

解决。

你可能感兴趣的:(maven重复引入jar包导致的一次问题)