java - 连接到 repo.maven.apache.org :443 failed

标签 java spring-boot maven jenkins

我正在尝试构建一个 spring-boot来自 jenkins 管道的 maven 项目。

错误:

ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for xxx.xxxxx.xxxx:finance-portal:0.0.1-SNAPSHOT: 
 Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.4.2 
 Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.2 
 from/to central (https://repo.maven.apache.org/maven2): 
 Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.24.215] failed: 
 Connection refused (Connection refused) and 'parent.relativePath' points at no local POM @ line 6, column 10

ma​​ven 目标:

clean install -U -X

pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.2</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

到目前为止我尝试过的解决方案:

  1. 通过 settings.xml 设置组织代理jenkins 中的文件并在管道中使用配置。

  2. 通过 Maven 目标设置代理:clean install -DproxySet=true -DproxyHost=proxy.com -DproxyPort=xxxxx .

  3. 省略/更改 relativePath pom.xml 中的标记为 <relativePath>../pom.xml</relativePath>和其他一些变体。

  4. 删除项目的 jenkins 工作区并重新构建它。

  5. 制作 curl在构建之前请求 Maven 中央仓库以检查连接建立:curl -I -x proxy.com:xxxxx "https://repo.maven.apache.org/maven2" .连接已建立,但在构建过程中失败。

最佳答案

我敢打赌您错过了一些配置代理设置的内容。例如,设置了错误的协议(protocol),或者您在 setting.xml 文件中拼错/放错了 proxies 标签。

这是 Apache 手册中的示例:

<settings>
  .
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
  .
</settings>

该协议(protocol)似乎是代理服务器的协议(protocol),而不是代理请求的协议(protocol)。这是关于这一点的长篇讨论:

How to configure a proxy server for both HTTP and HTTPS in Maven's settings.xml?

也有可能是你的 setting.xml 放错了地方。这是默认位置:

(Linux) /home/bob/.m2/settings.xml
(Windows) C:\Users\bob\.m2\settings.xml

IDE 或 CD/CI 管道可以覆盖默认位置。可以这样做:

mvn --settings your_location/settings.xml clean install
(or) 
mvn -s your_location/settings.xml clean install

另一个问题可能是与 JVM 代理配置的冲突。我不确定,哪个配置优先。 JVM 使用自己的参数:

http.proxyHost (default: <none>) 
http.nonProxyHosts (default: localhost|127.*|[::1])
http.proxyPort (default: 80)
https.proxyHost(default: <none>)
https.proxyPort (default: 443)

这里 httphttps 是代理请求的协议(protocol)(至少 AFAIU)

https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html

另一个可能的问题可能是参数 -Djava.net.useSystemProxies。如果设置为 true(默认 - false),则使用操作系统范围的代理配置。

关于java - 连接到 repo.maven.apache.org :443 failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69255452/

相关文章:

maven - 使用 Maven 执行 jmeter 测试时出现错误 "You must specify a valid lifecycle phase or a goal in the format"

java - 从内存中移除 ArrayList 对象

java - 如何在通过 Helm 部署的 Java Spring Boot 应用程序中使用来自 configmaps 的属性

java - 从Java中的子类构造函数填充父类(super class)中的 HashMap

java - Spring boot在添加mongo-java-driver maven依赖时尝试连接mongo

Spring Boot ServletRegistrationBean 和部署到外部 Tomcat

java - 如何防止 hibernate3-maven-plugin HBM2DDL 打印到控制台

java - @org.testng.annotations.Test 和 @org.junit.Test 问题

java - JUnit - 一次在@Before 中启动的字段在测试中为空

java - 为什么在 Hibernate 5 中不推荐使用条件查询?