如何解决Maven jar包依赖版本冲突(dependency collision)

本文将详细解释在使用Maven进行项目构建时,遇到的版本冲突问题如何导致编译成功但测试或安装后出现类方法未找到错误的情况,并提供了解决方法。通过打开pom.xml文件,使用MyEclipse工具查找问题的类包,排除不同版本依赖的问题,从而解决此类问题。

由于许多Jar包存在互相依赖关系,使用Maven构建项目时,容易产生版本问题。


问题现象:compile编译通过,但是test测试或者install后程序报错

提示 method not found,通过查看抛出异常的类,可以发现引用的class确实没有这个method,因为运行的时候,引用了另外一个版本的jar包。



解决方法:


step 1: 通过myeclipse打开pom.xml,打开dependency hierarchy,查找报错class对应的包

发现有些依赖beans 3.2.0的,有些依赖beans 3.2.8的。




step 2: 右键> Exclude Maven Artifact即可


08:48:02,812 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - 'File' option has the same value "C:\Users\86178/logs/nacos/config.log" as that given for appender [CONFIG_LOG_FILE] defined earlier. 08:48:02,812 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 08:48:02,812 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - 'File' option has the same value "C:\Users\86178/logs/nacos/naming.log" as that given for appender [NAMING_LOG_FILE] defined earlier. 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - 'File' option has the same value "C:\Users\86178/logs/nacos/remote.log" as that given for appender [REMOTE_LOG_FILE] defined earlier. 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 08:48:02,814 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision
06-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值