【问题标题】:Jersey-server Maven - Could not resolve dependencies for projectJersey-server Maven - 无法解析项目的依赖关系
【发布时间】:2021-04-03 15:32:32
【问题描述】:

Jersey 服务器似乎已移至 glassfish,但我更改为使用正确的 GAV 值,但我没有任何运气!一个简单的 Jersey helloworld REST 项目不会构建!这是我与泽西岛相关的 Maven 依赖项

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.25</version>
    </dependency>
    
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.25</version>
    </dependency>

这是我得到的错误:

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.xxxxxxx >----------------------
[INFO] Building xxxxxxx Server 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
Downloading from central: http://repo1.maven.org/maven2/org/glassfish/jersey/containers/jersey-container-servlet/2.25/jersey-container-servlet-2.25.pom
Downloading from central: http://repo1.maven.org/maven2/org/glassfish/jersey/core/jersey-server/2.25/jersey-server-2.25.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.197 s
[INFO] Finished at: 2020-12-25T13:41:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project restserver: Could not resolve dependencies for project com.xxxxxxx:restserver:war:0.0.1-SNAPSHOT: Failed to collect dependencies at org.glassfish.jersey.co
ntainers:jersey-container-servlet:jar:2.25: Failed to read artifact descriptor for org.glassfish.jersey.containers:jersey-container-servlet:jar:2.25: Could not transfer artifact org.glassfish.jersey.containers:jersey-container-servlet:pom:2.25 from/to central (http://repo1.maven.org/maven2): Failed to transfer file http://repo1.maven.org/maven2/org/glassfish/jersey/containers/jersey-container-serv
let/2.25/jersey-container-servlet-2.25.pom with status code 501 -> [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

【问题讨论】:

  • 尝试将repo1.maven.org/maven2 的协议从http 切换到https

标签: java maven jersey


【解决方案1】:

我将回答我自己的问题,这样可以帮助某人并且很容易引起注意。

这必须是最小的答案 - 在 settings.xml 中将“s”附加到 http。不确定我的其他项目是如何构建的。

出于好奇,在成功构建后,我删除了“s”并在没有任何更改的情况下重新构建了项目,它开始通过。它可能已经在我的本地存储库中缓存了二进制文件......然后最终在一段时间后开始失败,所以把它放回去!

【讨论】:

  • 我相信原因是 maven 的默认更新策略 daily - 因此,在您使用此存储库的适当访问协议成功构建项目后 - 依赖项已缓存在本地 maven 存储库中,因此用于以下构建白天,无论您设置的 repo 地址如何,都使用来自本地 repo 的缓存依赖项。然后,一天过去了,maven 尝试检查存储库是否有更新,再次遇到同样的问题,因为存储库不支持http
  • @Dornaut 绝对正确!我在我的 settings.xml 中检查了我的“updatePolicy”设置,它对于快照不存在。默认为每天根据:maven.apache.org/ref/3.6.3/maven-settings/settings.html。谢谢
猜你喜欢
  • 2020-09-09
  • 2022-01-23
  • 2015-06-04
  • 2015-09-01
  • 2015-01-14
  • 2014-09-05
  • 2021-08-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多