由于防火墙的原因,无法连接到组织内的Maven中央存储库,Maven无法连接到内部URL,在简单项目中失败



我在一个组织内工作,防火墙设置不允许从Maven Central存储库下载jar。相反,该组织创建了一个内部存储库https://internalurl它准确地反映了Maven中央存储库的目录或包结构

因此,在我的$HOME.m2\settings.xml中,我放置了以下条目,以便Maven构建使用internalurl,而不是Maven Central存储库

<settings xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<mirrors>
<mirror>
<id>central-proxy</id>
<name>Local proxy of central repo</name>
<url>https://internalurl</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings> 

接下来,我尝试创建一个简单的";Maven Web项目;在Eclipse上通过选择Archetype";maven原型webapp;GroupId org.apache.maven.protypes的1.0版本但一旦我输入Project GroupId、ArtifactId并单击Finish,我就会得到以下错误无法从任何配置的存储库中解析prototype org.apache.maven.protypes:maven-archetype-webap:1.0

Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://internalurl  was cached in the local repository, resolution will not be reattempted until the update interval of central-proxy has elapsed or updates are forced. Original error: Could not transfer artifact 

当我转到我们的内部Maven Repository网站,深入到下面的URL和包结构时,我可以看到Maven原型webapp:pom:1.0存在如果我去https://internalurl/org/apache/maven/archetypes/maven-archetype-webapp/1.0我可以看到以下2个文件

maven-archetype-webapp-1.0.jar
maven-aarchetype-webapp-1.0pom

那么,为什么Eclipse报告ERROR而不创建项目呢?请帮忙。

感谢

您必须更改您的设置,如下所示。

<mirror>
<id>central-proxy</id>
<name>Local proxy of central repo</name>
<url>https://internalurl</url>
<mirrorOf>*</mirrorOf>
</mirror>

根据下面的文档,因为<mirrorOf>central</mirrorOf>意味着指向Maven中央存储库的镜像。

Maven设置参考-镜像

Maven镜像指南

相关内容

最新更新