gpt4 book ai didi

java - 抑制 Maven 依赖插件的 "Unused declared dependencies found"警告

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:08:17 25 4
gpt4 key购买 nike

maven-dependency-plugin通过在编译时产生警告来识别它认为是未使用的依赖项。

[WARNING] Unused declared dependencies found:
[WARNING] org.foo:bar-api:jar:1.7.5:compile

在某些情况下,此消息是误报,并且依赖关系是可传递的。

问题:如何在我的 pom.xml 中识别出这种情况?

最佳答案

您应该在 pom 中配置 ignoredDependencies元素:

List of dependencies that will be ignored. Any dependency on this list will be excluded from the "declared but unused" and the "used but undeclared" list. The filter syntax is:

[groupId]:[artifactId]:[type]:[version]

where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard. *

也是官方指定的Exclude dependencies from dependency analysis .示例配置为:

<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>analyze-dep</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<ignoredDependencies>
<ignoredDependency>org.foo:bar-api:jar:1.7.5</ignoredDependency>
</ignoredDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

关于java - 抑制 Maven 依赖插件的 "Unused declared dependencies found"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36573510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com