更新:这种情况不会/不应该再发生,参见接受的回答。如果您在其他jar中遇到这个问题,这通常是暂时的。您可以尝试其他答案中建议的一些变通方法。
我正在遵循Jersey 2.0用户指南中的说明。当我达到1.3(运行项目)时,我得到以下失败:
[ERROR] Failed to execute goal on project xxx-service: Could not resolve dependencies for project xxx.restapi:xxx-service:jar:1.0-SNAPSHOT: Failure to find javax.annotation:javax.annotation-api:jar:1.2 in https://maven.java.net/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of snapshot-repository.java.net has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
问题似乎是没有https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
如果我们到https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/
,我们看到文件夹和jar文件在这些文件夹被重命名为后缀-b01
等。
pom本身没有对这个annotation jar的任何直接引用。所以我想问题是:我如何调整这种依赖关系?我在POM文件中放入什么才能正确解决依赖关系?
在此期间,此问题不再发生。javax.annotation:javax.annotation-api:jar:1.2
现在在Maven中心可用。
我不得不添加以下pom.xml
来解决这个问题:
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2-b04</version>
</dependency>
https://maven.java.net/content/groups/public/javax/annotation/javax.annotation-api/
查看最新版本。
javax.annotation-api.jar 1.2版本发布在java.net maven存储库@ https://maven.java.net
按此链接搜索版本1.2:
https://maven.java.net/index.html nexus-search; gav ~ javax.annotation ~ javax.annotation-api ~ ~ ~
1.2您可以通过将其添加到pom.xml的部分来指示maven从java.net maven存储库中获取工件。例如
<repositories>
<repository>
<id>java.net.repo</id>
<url>https://maven.java.net/content/groups/promoted/</url>
<layout>default</layout>
</repository>
</repositories>