我正在使用spring-boot
2.0.3.RELEASE
。当我使用IntelliJ IDEA
单击“显示有效POM”选项时,它将加载Effective POM
。在那我可以看到我的客户不想在那边拥有的一些依赖关系。
有没有办法告诉Maven
不包括这些依赖项?如何从有效pom中排除依赖项?
答案 0 :(得分:0)
Maven提供了一种使用exclude标签排除依赖项的方法
以下是来自文档网站https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
的示例 <dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
这个想法是从不需要的部门找到父母的依存关系,并添加一个排除标签。
如果在运行时需要它们,则可以指定要提供的范围
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
这将告诉Maven使用dep进行编译,但不将其包含在目标软件包中,并且将由JVM执行代码在生产环境中提供它们。
希望这会有所帮助