【问题标题】:Why do we need exclude in pom [duplicate]为什么我们需要在 pom 中排除 [重复]
【发布时间】:2016-04-27 23:06:26
【问题描述】:

Pom.xml 有这些元素,我很好奇为什么我们需要从 spring-core 中排除 commons-logging?它是如何工作的?

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.0.5.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>
<!-- next is log4j dependencie -->

【问题讨论】:

    标签: java spring maven pom.xml


    【解决方案1】:

    类似的事情我也见过,也做过,原因很简单:

    排除 commons-logging 库,因为我想改用 log4j

    所以你告诉 maven 不要包含不必要的库,并使用&lt; exclusion &gt;

    【讨论】:

      【解决方案2】:

      您的程序中可能使用的commons-logging 版本与spring-core 3.0.5.RELEASE 定义的版本不同。检查程序的依赖关系,看看是否定义了另一个commons-logging

      【讨论】:

        【解决方案3】:

        在上面的示例中,spring-core 本身依赖于 commons-logging,因此它会将那个 jar 拉到项目中。无论出于何种原因,用户不想要 spring-core 附带的 commons-logging,他们可能想要使用另一个版本。

        可能有 2 个具有相互冲突的子依赖项的依赖项,尽管我会说这种情况很少见。通常 excludes 可以谨慎使用。

        【讨论】:

          猜你喜欢
          • 2013-12-17
          • 2022-12-06
          • 1970-01-01
          • 1970-01-01
          • 2019-06-09
          • 2011-12-12
          • 1970-01-01
          • 2020-09-26
          • 1970-01-01
          相关资源
          最近更新 更多