海纳百川 - The following artifacts could not be resolved
Jenkins+Maven出现The following artifacts could not be resolved问题解决方案
背景项目采用Jenkins+Maven实现自动化部署springboot项目。本地运行正常，但是gitlab提交后，执行自动化部署过程中，出现了如下错误：[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:14 min [INFO] Finished at: 2022-03-14T06:17:49Z [INFO] ------------------------------------------------------------------------ Waiting for Jenkins to finish collecting data [ERROR] Failed to execute goal on project **-server: Could not resolve dependencies for project *****:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.apache.poi:poi-ooxml:jar:3.17, org.apache.xmlbeans:xmlbeans:jar:2.6.0: Could not transfer artifact org.apache.poi:poi-ooxml:jar:3.17 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.40.215] failed: Connection timed out (Connection timed out) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.这里的描述很清楚，本地找不到poi-ooxml包，去中央仓库下载，然后国内的网络环境下，无法在https://repo.maven.apache.org下载该包。导致了构建失败。过程及分析一、确认Jenkins配置是否正确首先我想到的是maven配置问题，因为我使用的是自己部署的nexus3私库，在Jenkins-管理管理-Managed files中添加了settings.xml文件并在项目中进行了配置使用。反复检查了settings.xml文件，确认没有问题。 nexus * http://私库Ip/nexus/repository/maven-public/ 二、nexus配置后来想到，可能是nexus中配置的代理仓库没有修改成国内镜像。查看后发现也没有问题。nexus中添加了阿里云镜像的代理仓库。并把其放在了靠前的位置。三、pom.xml配置以上检查无误后，陷入了僵局，这个问题困扰了我一整天。期间我一度想直接在本地拷贝了这个包放到Jenkins的本地仓库中，然后问题依然存在，o(╯□╰)o。直到后来，无意中查询到， 自定义pom.xml都是继承自super pom，所以maven项目下载一些jar包时，默认会从中央仓库下载 。知道了这点，剩下的就好办了，只要在pom.xml中进行配置，覆盖掉super pom的配置即可。 nexus http://nexus.dev.dhdc.com/nexus/repository/maven-public/ nexus http://nexus.dev.dhdc.com/nexus/repository/maven-public/