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

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

    >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更新?


当前回答

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

其他回答

我遇到这个问题的原因不同。我访问了maven存储库https://mvnrepository.com,寻找spring核心的最新版本,当时是5.0.0。M3/存储库为我的pom.xml显示了以下条目:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.0.M3</version>
</dependency>

我是个天真的傻瓜,我以为注释告诉我jar位于默认存储库中。

然而,在大量的头部撞击之后,我看到一个注释就在xml下面说“注:这个工件它位于Alfresco公共存储库(https://artifacts.alfresco.com/nexus/content/repositories/public/)”

所以XML中的注释完全是误导性的。这个罐子位于另一个存档中,这就是Maven找不到它的原因!

我试了这里所有的答案,但似乎都不管用。重启我的电脑,然后运行mvn clean install -U。这解决了我的问题。

使用mvn clean install -U run as maven test之后,使用maven-update project更新你的项目 这对我来说是可行的

以防有人只想更新项目的快照依赖项而不想安装工件:

mvn dependency:resolve -U

不要忘记在IDE中重新导入依赖项。在IDEA中,您需要右键单击pom文件,并选择Maven ->重新导入

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