简体   繁体   English

如何在maven中排除嵌套依赖项

[英]How to exclude nested dependency in maven

I have this dependency tree: 我有这个依赖树:

[INFO] +- org.springframework.ws:org.springframework.ws:jar:2.1.0.RELEASE:compile
[INFO] |  +- org.springframework:org.springframework.aop:jar:3.1.1.RELEASE:compile
[INFO] |  |  \- org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0:compile
[INFO] |  +- org.springframework:org.springframework.oxm:jar:3.1.1.RELEASE:compile
[INFO] |  \- org.springframework.ws:org.springframework.xml:jar:2.1.0.RELEASE:compile
[INFO] |     \- org.apache.ws:com.springsource.org.apache.ws.commons.schema:jar:1.3.2:compile

And I want to exclude (last one): 我想排除(最后一个):

org.apache.ws:com.springsource.org.apache.ws.commons.schema:jar:1.3.2 org.apache.ws:com.springsource.org.apache.ws.commons.schema:jar:1.3.2

which is (according to its pom): 这是(根据它的pom):

<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>

So I define in root artifact ( org.springframework.ws ): 所以我在root工件( org.springframework.ws )中定义:

<dependency>
    <groupId>org.springframework.ws</groupId>
    <artifactId>org.springframework.ws</artifactId>
    <version>2.1.0.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.ws.commons.schema</groupId>
            <artifactId>XmlSchema</artifactId>
        </exclusion>
    </exclusions>
</dependency>

And nothing really changes. 并没有什么真正改变。 Artifact I wanted to exclude is still present. 我想要排除的神器仍然存在。 Anyone can help me how to make it working? 任何人都可以帮助我如何让它工作?

Exclusion does not exclude separate class. 排除不排除单独的类。 It works with artifacts, ie jar files. 它适用于工件,即jar文件。 You indeed can exclude the third party dependency using tag like this: 您确实可以使用以下标记排除第三方依赖项:

    <exclusion>
        <groupId>org.apache.ws</groupId>
        <artifactId>com.springsource.org.apache.ws.commons.schema</artifactId>
    </exclusion>

Where: 哪里:

  • org.apache.ws is group ID org.apache.ws是组ID
  • com.springsource.org.apache.ws.commons.schema is artifact ID com.springsource.org.apache.ws.commons.schema是工件ID

(from your dependency tree example). (来自您的依赖树示例)。

I do not thing that there is a built-in ability to exclude specific class. 我不认为有内置的能力来排除特定的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM