我的新项目需要javax.xml包。我在mvnrepository.com上搜索了一下,找到了one:
<!-- https://mvnrepository.com/artifact/javax.xml/jaxrpc-api -->
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>2.0_EA1</version>
</dependency>我想,第一个注释行是包存储库。如果我说错了,请纠正我。我在我的pom.xml中添加了以下部分
<repositories>
<repository>
<id>repo1</id>
<name>Repo 1</name>
<url>https://mvnrepository.com/artifact/javax.xml/jaxrpc-api</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>2.0_EA1</version>
</dependency>
</dependencies>但是看起来我搞错了maven地址。
mvn compile带来错误:
[ERROR] Failed to execute goal on project test-xpath: Could not resolve dependencies for project com.kkk:test-xpath:jar:0.0.1-SNAPSHOT: Failure to find javax.xml:jaxrpc-api:jar:2.0_EA1 in https://mvnrepository.com/artifact/javax.xml/jaxrpc-api was cached in the local repository, resolution will not be reattempted until the update interval of repo1 has elapsed or updates are forced -> [Help 1]我做错了什么,怎么改正?
更新
删除存储库后,我收到错误:
Failed to execute goal on project test-xpath: Could not resolve dependencies for project com.kkk:test-xpath:jar:0.0.1-SNAPSHOT: Failure to find javax.xml:jaxrpc-api:jar:2.0_EA1 in https://mvnrepository.com/artifact/javax.xml/jaxrpc-api was cached in the local repository, resolution will not be reattempted until the update interval of repo1 has elapsed or updates are forced -> [Help 1]UPD2
我了解到我应该将spring存储库添加到我的依赖项中:
<repositories>
<repository>
<id>repo1</id>
<name>Repo 1</name>
<url>http://repo.spring.io/plugins-release/</url>
</repository>
</repositories> 我已经删除了.m2\repository\javax和maven clean
maven compile产生的错误:
Downloading from repo1: http://repo.spring.io/plugins-release/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.pom
Downloaded from repo1: http://repo.spring.io/plugins-release/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.pom (395 B at 736 B/s)
Downloading from repo1: http://repo.spring.io/plugins-release/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.jar
Downloading from central: https://repo.maven.apache.org/maven2/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.767 s
[INFO] Finished at: 2018-11-07T14:17:38+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test-xpath: Could not resolve dependencies for project com.kkk:test-xpath:jar:0.0.1-SNAPSHOT: Could not find artifact javax.xml:jaxrpc-api:jar:2.0_EA1 in repo1 (http://repo.spring.io/plugins-release/), try downloading from https://jax-rpc.dev.java.net/jaxrpc20-ea/ -> [Help 1]如果我在我的pom.xml中没有<repository>的情况下执行相同的操作,并执行maven compile,我也会遇到相同的错误,但它会尝试从maven.repo下载pom。
Downloading from central: https://repo.maven.apache.org/maven2/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.pom (395 B at 987 B/s)
Downloading from central: https://repo.maven.apache.org/maven2/javax/xml/jaxrpc-api/2.0_EA1/jaxrpc-api-2.0_EA1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.180 s
[INFO] Finished at: 2018-11-07T14:31:44+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test-xpath: Could not resolve dependencies for project com.kpv:test-xpath:jar:0.0.1-SNAPSHOT: Could not find artifact javax.xml:jaxrpc-api:jar:2.0_EA1 in central (https://repo.maven.apache.org/maven2), try downloading from https://jax-rpc.dev.java.net/jaxrpc20-ea/ -> [Help 1]发布于 2018-11-07 18:27:35
这不是存储库标签的正确用法。如果你转到https://mvnrepository.com主页,你会看到它从多个存储库创建索引,比如central,jcenter等,所以你必须使用标准存储库。
发布于 2018-11-07 18:51:33
如果我们打开maven repository页面,我们可以看到两个选项卡: Central和Spring Plugins。打开Spring plugins选项卡,尝试使用它,因为该版本是最新的,日期是2018年4月。
<!-- https://mvnrepository.com/artifact/javax.xml/jaxrpc-api -->
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>2.0_ea1</version>
</dependency>另外,运行mvn clean命令,并确保删除.m2位置中的javax文件夹。
发布于 2018-11-07 19:29:34
2.0_EA1在Maven central上不存在。如果你使用的是1.1,你会发现它是有效的。非标准化的semver版本似乎与非官方版本相关,可能是alpha版本。对search.maven.org的搜索声称它存在,但jar本身并不存在
使用工作版本进行检查的步骤:
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>1.1</version>
</dependency>
</dependencies>还要注意: maven显示的错误告诉您可以从url手动下载jar,它不是存储库。
为了只回答问题的标题,您可以在pom.xml中添加一个存储库,但不需要添加中央maven存储库,因此我为您提供了另一个存储库的示例:
<repositories>
<repository>
<id>jitpack</id>
<name>jitpack</name>
<url>https://jitpack.io</url>
</repository>
</repositories>https://stackoverflow.com/questions/53187425
复制相似问题