Maven - 设置中的代理会导致公司关系的连接错误



>我正在使用以下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:Devm2</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>
            </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>

其中配置了代理设置和公司关系。我想要代理设置,因为在其中一个项目中,我配置了 maven 中央存储库

<repository>
            <id>maven-central</id>
            <url>http://repo1.maven.org/maven2</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
</repository>

但是,当一个可以从公司 Nexus 检索所有内容的项目(即不需要通过代理访问http://repo1.maven.org/maven2时,我得到

[ERROR] Failed to execute goal on project someproject: Could not resolve dependencies for project groupId:artifactId:jar:1.0-SNAPSHOT: 
Failed to collect dependencies at junit:junit:jar:4.12: Failed to read artifact descriptor for junit:junit:jar:4.12: 
Could not transfer artifact junit:junit:pom:4.12 from/to central (http://company-nexus.com): 
Access denied to: http://company-nexus.com/nexus/content/groups/public/junit/junit/4.12/junit-4.12.pom, ReasonPhrase: URLBlocked. -> [Help 1]

当我删除settings.xml中的代理设置时,我获得了构建成功。

同样,我需要为某些但不是所有项目提供这些代理设置,因为我们公司 nexus 拥有大部分存储库

感谢您的帮助!

非代理主机标记中添加本地 nexus 存储库主机名

<nonProxyHosts>localhost|company-deploy-nexus.com|company-nexus.com|localhost</nonProxyHosts>

最新更新