# 无法从/向中央仓库 (https://repo.maven.apache.org/maven2) 传输工件 com.example:lib:1.0.0：代理认证失败：需要代理认证。

- **ID:** `java/maven-proxy-authentication-failure`
- **领域:** java
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Maven 配置为使用需要认证的代理，但凭据缺失或不正确。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 8+ | active | — | — |

## 解决方案

1. **Configure the proxy with correct credentials in settings.xml** (95% 成功率)
   ```
   <proxies><proxy><id>myproxy</id><username>user</username><password>pass</password><host>proxy.company.com</host><port>8080</port></proxy></proxies>
   ```
2. **Use environment variables for proxy authentication** (90% 成功率)
   ```
   export MAVEN_OPTS='-Dhttp.proxyHost=proxy.company.com -Dhttp.proxyPort=8080 -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass'
   ```

## 无效尝试

- **Disabling the proxy in settings.xml** — If the network requires a proxy, disabling it will cause connection timeouts. (80% 失败率)
- **Using incorrect credentials in settings.xml** — The proxy will reject the authentication, and the build will fail. (90% 失败率)
