Warning maven relocated xml-apis to 1.0.b

maven 依赖

在maven项目中,一些基础的jar包被引用多次是很常见的事情。maven选择jar的版本是基于
- 依赖深度浅的 比如C项目依赖xml.jar。C依赖的B也引入了xml.jar。那么优先选择C中指定的
- 如果依赖深度一样,第一次依赖的jar被选中

实际项目开发,一般是exclude掉B项目中的xml.jar,在C项目中显示指定xml.jar的版本。

<dependency>
    <groupId></groupId>
    <artifactId>test</artifactId>
    <version>1.0</version>
    <exclusions>
        <exclusion>
            <groupId>xml</group>
            <artifactId>xml</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>xml</group>
    <artifactId>xml</artifactId>
    <version> 2.2</version>
</dependency>

问题

按照上面的原则对xml-apis.1.0.b进行升级到xml-apis.1.4。但是始终exclude不出去xml-apis1.0.b
mvn dependency:tree

看到xml-apis.1.0.的来源已经不是依赖的项目中引入的,而是在根路径下。

这个颠覆了对maven的认知。

这里写图片描述

看了下xml-apis这个,就知道版本有多混乱了,2.0.2的比1.4的还要先发布。

解决

直接引入了xerces xercesImpl 2.10.0.这个jar包中有xml-apis1.4.01版本

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.10.0</version>
</dependency>

参考

http://javamoods.blogspot.com/2009/06/maven-how-relocated-artifacts-can-ruin.html
https://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven?answertab=votes
https://gxnotes.com/article/29548.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

方丈的寺院

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值