根据文档,我在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>
Run Code Online (Sandbox Code Playgroud)
我需要使用dependencyManagement,<scope>import</scope>因为我需要使用标准的企业基础pom.
但是,似乎不可能排除传递依赖性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>
Run Code Online (Sandbox Code Playgroud)
使用Maven 3.2.1的通配符支持,但它似乎没有生效.
除了显式覆盖所有Jetty依赖项之外,是否有解决此问题的方法?有许多Jetty库,这种方法会非常脆弱.此外,我似乎也需要对Jetty的传递依赖性做同样的事情.
根据Spring Boot Maven Plugin 2.3.1.RELEASE 文档,要覆盖各个依赖项,您需要在dependencyManagement项目部分的条目之前spring-boot-dependencies添加条目。
<dependencyManagement>
<dependencies>
<!-- Your jetty version dependency -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>*</artifactId>
<version>${jetty.version}</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
看起来这对于 Maven 导入范围来说是不可能的:
导入范围可用于将远程 POM 中的依赖关系管理信息包含到当前项目中。其局限性之一是它不允许为多模块项目定义额外的排除项。
同样, Spring Boot 文档也有确认:
如果您在自己的
dependencyManagement部分中添加了 spring-boot-dependency,则<scope>import</scope>必须自己重新定义工件[...]。
| 归档时间: |
|
| 查看次数: |
3676 次 |
| 最近记录: |