我有一个漂亮的BOM,其dependencyManagement部分有很多依赖项,我想创建另一个BOM,导入除了一个以外的所有依赖项.我试过这样做:
... in my dependencyManagement section
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-version}</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>
...
Run Code Online (Sandbox Code Playgroud)
POM正式正确,一切都在编译.但排除被忽略了.我错过了什么?这种方法是否正确?
我正在使用Maven 3+.
从当前的 maven 3.6.3 开始,dependencyManagement 仍未实现排除。但是,您可以将项目特定的“物料清单”(BOM) 作为第一个依赖项包含在 dependencyManagement 部分中,即
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my-group</groupId>
<artifactId>my-group-project-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<type>pom</type>
<version>${spring-boot.version}</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
然后,您可以在项目 BOM 中指定所有必要的工件版本,这些版本将优先于 spring-boot 依赖项版本。
导入时排除不起作用,请尝试将其从依赖项的实际用户中排除
| 归档时间: |
|
| 查看次数: |
5175 次 |
| 最近记录: |