我将我已经工作的项目导入到另一台计算机上,它开始下载依赖项。

显然我的网络连接崩溃了,现在我得到了以下信息:

    >Build errors for comics; org.apache.maven.lifecycle.LifecycleExecutionException:
    Failed to execute goal on project comicsTest: Could not resolve dependencies for project comicsTest:comicsTest:war:0.0.1-SNAPSHOT:
    The following artifacts could not be resolved:
    org.springframework:spring-context:jar:3.0.5.RELEASE,
    org.hibernate:hibernate-entitymanager:jar:3.6.0.Final,
    org.hibernate:hibernate-core:jar:3.6.0.Final,
    org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final,
    org.aspectj:aspectjweaver:jar:1.6.8,
    commons-lang:commons-lang:jar:2.5,

    >mysql:mysql-connector-java:jar:5.1.13: Failure to transfer org.springframework:spring-context:jar:3.0.5.RELEASE from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced.

    >Original error: Could not transfer artifact org.springframework:spring-context:jar:3.0.5.RELEASE from central (http://repo1.maven.org/maven2): No response received after 60000

如何强制maven更新?


当前回答

这里所有的答案对我都不起作用。我用了锤子法:

find ~/.m2/ -name "*.lastUpdated" | xargs rm

这解决了问题:-)

其他回答

要从Eclipse中修复此问题:

1)在Maven pom.xml中添加以下依赖项,并保存pom.xml文件。

<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
    <groupId>com.thoughtworks.xstream</groupId>
    <artifactId>xstream</artifactId>
    <version>1.3.1</version>
</dependency>

2)进入项目>> Maven >>更新项目

选择项目并单击OK。

3)可选步骤,如果到第2步还没有解决,在第1步之后再执行下一步骤

转到项目>> Maven >>更新项目>>检查复选框中的“强制更新快照/发布”

选择项目并单击OK。

我有同样的错误与android-maps-utils依赖。使用aar类型包在依赖部分解决我的问题。 默认类型是jar,因此可能会检查在存储库中下载的依赖项类型。

您需要检查<maven_home>/conf目录下的settings.xml文件。

What maven does is, it downloads all your project's dependencies into your local repo (.m2 folder). Because of the internet causing issues with your local repo, you project is facing problems. I am not sure if this will surely help you or not but you can try deleting all the files within the repository folder inside the .m2 folder. Since there would be nothing in the local repo, maven would be forced to download the dependencies again, thus forcing an update. Generally, the .m2 folder is located at c:users:[username]:.m2

如果你的本地存储库在某种程度上为发布jar而不是快照(-U和——update-snapshots只更新快照)搞砸了,你可以使用以下命令清除本地回购:

 mvn dependency:purge-local-repository

然后你可能想要清理并重新安装:

 mvn dependency:purge-local-repository clean install

更多信息请访问https://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html