You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

企业HTTP代理环境下artifactory-maven-plugin忽略代理设置致超时求助

解决Artifactory Maven插件忽略企业HTTP代理的问题

1. 直接在插件配置中指定代理

Artifactory Maven插件支持在自身配置里单独设置代理,这是最直接的解决方案。在pom.xml的插件配置中添加<proxy>节点:

<plugin>
    <groupId>org.jfrog.plugins</groupId>
    <artifactId>artifactory-maven-plugin</artifactId>
    <version>3.18.3</version> <!-- 建议使用最新稳定版 -->
    <configuration>
        <!-- 代理配置 -->
        <proxy>
            <host>你的企业代理主机</host>
            <port>代理端口</port>
            <!-- 若代理需要认证,添加以下内容 -->
            <username>代理用户名</username>
            <password>代理密码</password>
            <!-- 排除不需要走代理的内部域名,用|分隔 -->
            <nonProxyHosts>localhost|127.0.0.1|*.内部域名.com</nonProxyHosts>
        </proxy>
        <!-- 插件原有配置 -->
        <contextUrl>https://artifactory.x.eu/artifactory</contextUrl>
        <!-- 其他必要配置(如发布仓库、快照仓库等) -->
    </configuration>
</plugin>

2. 通过JVM系统参数强制指定代理

如果不想修改pom.xml,可以在CI/CD的Maven命令中添加JVM代理参数,让插件强制使用代理(插件底层会读取Java系统属性):

mvn clean install artifactory:deploy \
  -Dhttp.proxyHost=你的代理主机 \
  -Dhttp.proxyPort=代理端口 \
  -Dhttps.proxyHost=你的代理主机 \
  -Dhttps.proxyPort=代理端口 \
  -Dhttp.nonProxyHosts="localhost|*.内部域名.com"

注意:如果代理需要认证,还需添加-Dhttp.proxyUser和-Dhttp.proxyPassword参数

3. 检查并修正Maven settings.xml的代理配置

确认/root/.m2/settings.xml中的代理配置是否完整,特别是HTTPS协议的代理:

<proxies>
    <proxy>
        <id>http-proxy</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>代理主机</host>
        <port>代理端口</port>
        <nonProxyHosts>localhost|*.内部域名.com</nonProxyHosts>
        <username>代理用户名</username>
        <password>代理密码</password>
    </proxy>
    <proxy>
        <id>https-proxy</id>
        <active>true</active>
        <protocol>https</protocol>
        <host>代理主机</host>
        <port>代理端口</port>
        <nonProxyHosts>localhost|*.内部域名.com</nonProxyHosts>
        <username>代理用户名</username>
        <password>代理密码</password>
    </proxy>
</proxies>

确保<active>设为true,且Artifactory的域名不在<nonProxyHosts>中

4. 升级Artifactory Maven插件版本

旧版本的插件可能存在读取Maven全局代理配置的bug,建议升级到官方最新稳定版,替换pom.xml中的插件版本号即可。

内容的提问来源于stack exchange,提问作者pawl133

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 06:52:54