简体   繁体   English

从Spring上下文的传递依赖中排除Maven依赖

[英]Maven dependency exclusion from transitive dependency of spring-context

I want to exclude the common-logging from spring-core but spring-core is a transitive dependency for spring-context . 我想从spring-core排除common-logging ,但是spring-corespring-context的传递依赖spring-context I did it in the next way, but it seem to me that there is more properly way. 我以另一种方式做到了,但是在我看来,还有一种更合适的方式。 What is it??? 它是什么???

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

You can exclude transitive dependencies, see Introduction to the Dependency Mechanism : 您可以排除传递依赖,请参见依赖机制简介

  • Excluded dependencies - If project X depends on project Y, and project Y depends on project Z, the owner of project X can explicitly exclude project Z as a dependency, using the "exclusion" element. 排除的依赖项 -如果项目X依赖于项目Y,而项目Y依赖于项目Z,则项目X的所有者可以使用“ exclusion”元素将项目Z显式排除为依赖项。

Example: 例:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <exclusions>
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

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

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