我正在尝试在我的settings.xml中包含maven central repo http://repo1.maven.org/maven2
以及代理设置来访问它,因为公司nexus不包含我需要的最新存储库之一。
然而,当我mvn clean install
时,我收到以下错误
[INFO] Scanning for projects...
[ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.the.repo.that.I.need:
Failure to find org.the.repo.that.I.need:pom:1.0-SNAPSHOT in http://company-nexus.com was cached in the local repository,
resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM
因此它尝试从http://company-nexus.com
而不是http://repo1.maven.org/maven2
获取pom和jar。我怎么能改变它?
这是我的settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:\Dev\m2</localRepository>
<proxies>
<proxy>
<id>1</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>pass</password>
<host>host</host>
<port>port</port>
<nonProxyHosts>127.0.0.1|localhost|maven</nonProxyHosts>
</proxy>
<proxy>
<id>1</id>
<active>true</active>
<protocol>https</protocol>
<username>user</username>
<password>pass</password>
<host>host</host>
<port>port</port>
<nonProxyHosts>127.0.0.1|localhost|maven</nonProxyHosts>
</proxy>
</proxies>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>nexus1</id>
<url>http://company-nexus.com</url>
</repository>
<repository>
<id>nexus2</id>
<url>http://company-deploy-nexus.com</url>
</repository>
<repository>
<id>nexus3</id>
<url>ttp://company-deploy-nexus2.com</url>
</repository>
<repository>
<id>maven-central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus1</id>
<url>http://company-nexus.com</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<pluginGroups>
<pluginGroup>com.atlassian.maven.plugins</pluginGroup>
</pluginGroups>
</settings>
修改
它加载正确的settings.xml(在我的C:\Dev\m2
文件夹中)
[DEBUG] Reading global settings from C:\Dev\apache-maven-3.5.2\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\name\.m2\settings.xml
[DEBUG] Reading global toolchains from C:\Dev\apache-maven-3.5.2\conf\toolchains.xml
[DEBUG] Reading user toolchains from C:\Users\name\.m2\toolchains.xml
[DEBUG] Using local repository at C:\Dev\m2
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Dev\m2
我会再次尝试将maven中央仓库放入.pom
而不是settings.xml
感谢您的帮助!