设置Maven仓库

我的新项目需要 javax.xml 包。我确实在 mvnrepository.com 中搜索并找到了一个:


<!-- 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]

我做错了什么以及如何解决?


UPD


删除存储库后,我收到错误:


 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

炎炎设计
浏览 243回答 3
3回答

largeQ

这不是存储库标签的正确使用。如果您转到https://mvnrepository.com主页,您会看到它从多个存储库(例如 central、jcenter 等)生成索引。因此您必须使用标准存储库。

饮歌长啸

如果我们打开maven 存储库页面,我们可以看到两个选项卡:Central 和 Spring Plugins。打开 Spring 插件选项卡,并尝试使用它,因为该版本是最新的,日期为 2018 年 4 月。<!-- https://mvnrepository.com/artifact/javax.xml/jaxrpc-api --><dependency>&nbsp; &nbsp; <groupId>javax.xml</groupId>&nbsp; &nbsp; <artifactId>jaxrpc-api</artifactId>&nbsp; &nbsp; <version>2.0_ea1</version></dependency>此外,运行mvn clean命令,并确保删除位置中的javax文件夹.m2。

喵喵时光机

2.0_EA1 在 Maven 中心不存在。如果您使用 1.1,您将看到它有效。非规范化 semver 版本似乎与非官方版本有关,可能是 alpha 版本。search.maven.org 上的搜索声称它存在,但 jar 本身不存在要检查工作版本:<dependencies>&nbsp; <dependency>&nbsp; &nbsp; <groupId>javax.xml</groupId>&nbsp; &nbsp; <artifactId>jaxrpc-api</artifactId>&nbsp; &nbsp; <version>1.1</version>&nbsp; </dependency></dependencies>另请注意:maven 显示的错误告诉您可以从 url 手动下载 jar,它不是存储库。只回答问题的标题可以在pom.xml中添加一个仓库,但是maven中央仓库不需要添加,所以我给你举个例子,另一个仓库:<repositories>&nbsp; &nbsp; <repository>&nbsp; &nbsp; &nbsp; &nbsp; <id>jitpack</id>&nbsp; &nbsp; &nbsp; &nbsp; <name>jitpack</name>&nbsp; &nbsp; &nbsp; &nbsp; <url>https://jitpack.io</url>&nbsp; &nbsp; </repository></repositories>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java