【Q&A】Maven 打包错误:Failed to collect dependencies at org.springframework.integration

Failed to collect dependencies at org.springframework.integration

错误描述

[ERROR] Failed to execute goal on project ******: Could not resolve dependencies for project com.******😗**:jar:.: Failed to collect dependencies at org.springframework.integration:spring-integration-ip:jar:4.3.18.RELEASE: Failed to read artifact descriptor for org.springframework.integration:spring-integration-ip:jar:4.3.18.RELEASE: Could not transfer artifact org.springframework.integration:spring-integration-ip:pom:4.3.18.RELEASE from/to central (https://repo.maven.apache.org/maven2): connect 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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

问题分析

根据问题描述,可知是由于无法解决项目依赖问题导致。涉及的依赖包是org.springframework.integration:

  • 在org.springframework.integration上收集依赖项失败
  • 未能读取org.springframework.integration的构件描述符
  • 无法从Maven中心(https://repo.maven.apache.org/maven2)传递组件spring-integration-ip:pom:4.3.18.RELEASE: 连接超时

初步分析,可能是本地的repo有问题。

解决方案

首先介绍几个mvn命令:

  • mvn -U clean install: -U,–update-snapshots Forces a check for updated releases and snapshots on remote,即通过-U命令强制从远程仓库重新下载相关的dependency
  • mvn clean install -DskipTests:与上边同理,-DskipTests,即跳过测试代码
  • mvn package:Maven打包编译

通过命令行控制台,进入到project的目录中,即含有POM.xml的文件夹,执行任一上述命令,均能看到如下结果:
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46.380 s
[INFO] Finished at: 2020-05-12T17:54:24+08:00
[INFO] ------------------------------------------------------------------------
即编译成功。

注意:此时需要能够在命令行中执行Maven命令,即Maven注册在了环境变量里。

或者,我们使用Eclipse进行打包编译。这里,我们使用的Maven配置文件位置是.m2/setting.xml,使用的是镜像地址是
https://maven.aliyun.com/repository/central,配置如下:

<mirrors>
		<mirror>
			<id>aliyunmaven</id>
			<mirrorOf>*</mirrorOf>
			<name>central</name>
			<url>https://maven.aliyun.com/repository/central</url>
		</mirror>
	</mirrors>

然后执行update project,Run maven build,执行编译过程。需要注意的是,如果网络环境差,还是会导致这样的错误。如果仍然出现错误,则将对应的jar包下载后导入到Eclipse中。
最后,分享一个Aliyun的Maven仓库:https://maven.aliyun.com/mvn/view

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

镰刀韭菜

看在我不断努力的份上,支持我吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值