继续我的上一个问题not-able-to-locate-artifact-in-maven-repository,我能够在Maven存储库中找到 Artifact ,从而在pom.xml中添加 Artifact 的相应URL。
我仍然无法从Maven存储库下载 Artifact 。
Could not resolve dependencies for project com.indore:galaxy:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.4.1: Failed to read artifact descriptor for org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.4.1: Could not transfer artifact org.elasticsearch.client:elasticsearch-rest-high-level-client:pom:7.4.1 from/to nexus (http://nexus.dev.<my-company-name>.com/nexus/content/groups/public): nexus.dev.<my-company-name>.com: nodename nor servname provided, or not known:
所以有人可以告诉我我想念的东西吗?
编辑1
如@Opster Elasticsearch Ninja所述,我在
maven settings.xml
中提供了mirror标签<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus.dev.<my-company>.com/nexus/content/groups/public</url>
</mirror>
并且,Intellij maven设置为:
最佳答案
问题原因:
即使您在pom.xml中指定了公共(public)存储库,Intellij也会检查在maven settings.xml中定义的这些存储库的设置,更多说明in this SO answer.
现在,当您使用已安装的Maven版本时,IntelliJ正在使用maven .m2
文件夹中存在的settings.xml。根据您的mirror
标记,对于所有存储库(使用通配符*
),正在使用您的公司存储库。
当您那时未连接到公司VPN时,Maven无法连接到您的存储库,因此会引发错误节点名或提供的服务器名,或者未知:,因此无法从存储库下载 Artifact ,但是当存储库可访问,它将下载 Artifact 。
this SO answer中详细介绍了有关mirror标签的内容,并解释了*
的mirrorof
值。
解:
mirrorOf
标记值从*
更改为仅公司回购的特定id
。 id
,那么现在请注释mirror
标记并重试,maven应该连接到pom.xml
中提到的公共(public)回购并下载 Artifact 。 关于java - 未连接到公司VPN时从Maven存储库下载 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59640855/