设置Maven存储库

问题描述:

我的新项目需要javax.xml软件包.我确实在mvnrepository.com中进行了搜索,发现一个:>

I was needed for javax.xml package for my new project. I did search in mvnrepository.com and found 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中添加了以下部分:

I suppose, first comment line is package repository. Please, correct me if I'm wrong. I added following sections in my 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地址.

But looks I got wrong maven address.

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]

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

What I did wrong and how to fix that?

UPD

删除存储库后出现错误:

After removing repository I got 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]

UPD2

我了解到应该将spring存储库添加到我的依赖项中:

I have learned that I should add spring repository to my dependencies:

    <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.

In case I do the same action without <repository> in my pom.xml and do maven compile I have the same error, but it tries to download pom from maven.repo.

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]

2.0_EA1在Maven Central中不存在.如果您使用1.1,将会看到它的工作原理.非规范化的semver版本似乎与非官方版本有关,可能是alpha版本. 在search.maven.org上的搜索声称它存在,但jar本身不存在

2.0_EA1 doesn't exists on Maven central. if you use 1.1 you will see that it works. The non normalized semver version seem to relate to a non official version, maybe an alpha version. The search on search.maven.org claims it exists, but the jar itself doesn't exists

要查看工作版本,请执行以下操作:

To check with a working version:

<dependencies>
  <dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxrpc-api</artifactId>
    <version>1.1</version>
  </dependency>
</dependencies>

还请注意:错误Maven显示会告诉您,您可以从URL(不是存储库)中手动下载jar.

Also note: The error maven displays tell you that you can download the jar manually from an url, it's not a repository.

仅回答问题的标题,您可以将存储库添加到pom.xml中,但是不需要添加中央maven存储库,因此,我为您提供另一个存储库的示例:

To answer only the title of the question you can add a repository to your pom.xml, but the central maven repository dosen't need to be added, so I give you an example for another repository:

<repositories>
    <repository>
        <id>jitpack</id>
        <name>jitpack</name>
        <url>https://jitpack.io</url>
    </repository>
</repositories>