[英]Maven cannot Download from local repository (nexus) for some dependency or plugins
[英]Why public Maven dependency exist, but cannot download, and how to fix? This failure was cached in the local repository and resolution is not re
文件pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Foo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PCDRetention</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk16</artifactId>
<version>1.45</version>
</dependency>
<dependency>
<groupId>org.sonatype.sisu.inject</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.3</version>
</dependency>
<!-- asm-all:3.3.1 cannot migrate. -->
<!--<dependency>-->
<!-- <groupId>org.aspectj</groupId>-->
<!-- <artifactId>aspectjrt</artifactId>-->
<!-- <version>1.6.6</version>-->
<!-- <scope>runtime</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!-- <groupId>org.aspectj</groupId>-->
<!-- <artifactId>aspectjweaver</artifactId>-->
<!-- <version>1.6.6</version>-->
<!-- <scope>runtime</scope>-->
<!--</dependency>-->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</project>
幾乎所有的依賴都能下載,很少有依賴不能下載。
commons-dbcp:commons-dbcp:pom:1.4 failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact commons-dbcp:commons-dbcp:pom:1.4 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.pom
Try to run Maven import with -U flag (force update snapshots)
我不喜歡解決方案從 JAR 文件安裝本地 Maven。 怎么修?
最簡單的解決方案就是從本地 maven 存儲庫中刪除工件並重新運行導入。 如果您尚未修改 maven 設置以指向非默認存儲庫路徑,您將在~/.m2/repository/commons-dbcp/commons-dbcp/1.4
中找到工件。 刪除此目錄並重新運行導入。
Maven 有一個管理其行為的設置文件。 它位於$M2_HOME/conf
中,其中$M2_HOME
是 maven 安裝的主目錄。 此文件稱為settings.xml
。
您可以使用<localRepository/>
指令更改 maven 存儲它拉下的工件的位置。 您可以在此處找到此設置和其他設置的參考文檔。
本質上,您只需要找到本地工件的存儲位置並刪除該工件。 默認位於您的主目錄下的文件夾.m2/repository
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.