如何从maven导入范围中排除spring-boot-dependencies的传递依赖性

时间:2015-01-14 01:25:12

标签: maven spring-boot

根据the documentation我的Spring Boot应用程序pom中有以下内容:

  <dependencyManagement>
    <dependencies>
      <!-- Spring -->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

我需要使用dependencyManagement<scope>import</scope>,因为我需要使用标准的企业基础。

但是,似乎不可能排除spring-boot-dependencies的传递依赖关系。在我的特定情况下,Spring Boot 1.2.1.RELEASE引入了一个Jetty版本,这个版本对于我的其他<dependencies>来说太新了。我尝试使用表单的<exclusion>

  <dependencyManagement>
    <dependencies>
      <!-- Spring -->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>

        <!-- Doesn't work -->
        <exclusions>
          <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>*</artifactId>
          </exclusion>
        </exclusions>

      </dependency>

    </dependencies>
  </dependencyManagement>

使用Maven 3.2.1's wildcard support,但它似乎没有生效。

除了显式覆盖所有Jetty依赖项之外,是否有解决此问题的方法?有许多Jetty库,这种方法会非常脆弱。此外,我似乎也需要对Jetty的传递依赖性做同样的事情。

2 个答案:

答案 0 :(得分:2)

根据Spring Boot Maven Plugin 2.3.1.RELEASE documentation,要覆盖各个依赖项,您需要在项目的dependencyManagement部分中添加条目,}条目之前。 / p>

spring-boot-dependencies

答案 1 :(得分:1)

看起来像isn't possible with Maven import scope

  

导入范围可用于包括依赖关系管理   从远程POM到当前项目的信息。其中一个   这方面的限制是它不允许额外的排除   为多模块项目定义

同样,来自Spring Boot documentation

的确认
  

如果您已在自己的游戏中添加了spring-boot-dependencies   您需要dependencyManagement <scope>import</scope>部分   自己重新定义神器 [...]。

相关问题