简体   繁体   中英

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

which is (according to its pom):

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

So I define in root artifact ( 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. 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
  • com.springsource.org.apache.ws.commons.schema is artifact ID

(from your dependency tree example).

I do not thing that there is a built-in ability to exclude specific class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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