首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven回购不起作用

Maven回购不起作用
EN

Stack Overflow用户
提问于 2014-08-08 09:44:39
回答 3查看 2.8K关注 0票数 1

我正在尝试添加一个maven存储库mvnrepository.com,但是我似乎无法做到这一点。

代码语言:javascript
复制
<repository>
    <id>mvnrepository</id>
    <url>http://mvnrepository.com/artifact/</url>         
</repository>

我能清楚地看到我要找的艺术品是http://mvnrepository.com/artifact/org.springframework.ldap/spring-ldap/1.3.1.RELEASE

但是我的maven构建输出告诉我,它不是

下载:无法在存储库find存储库( 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE‘)中找到资源http://mvnrepository.com/artifact//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息

我做错了什么?如何下载spring工件?

更新我试过几个工匠工厂,但都失败了

下载:无法在存储库maven中心回购( 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE‘)中找到资源'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE’(http://repo1.maven.org/maven2/)下载:http://download.java.net/maven/2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息无法在存储库中找到资源‘org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE’java.net repo (http://download.java.net/maven/2/)下载:http://maven.springframework.org/external//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息无法找到资源的org.Spring repository work.ldap:spring:jar:1.3存储库春季外部( 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE‘)下载:在存储库repo.jenkins-ci.org (http://search.maven.org/)下载中无法找到资源'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE’的http://search.maven.org//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息:无法在存储库find存储库(https://repository.jboss.org/)中找到资源‘org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE’的https://repository.jboss.org//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息:无法找到资源的http://repo1.maven.org/maven2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息存储中心中的'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE‘(http://repo1.maven.org/maven2/)

如果我没有在settings.xml中定义任何存储库,则响应如下:

下载:无法在存储库中心( 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE‘)找到资源http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar信息(http://repo1.maven.org/maven2)

此外,我在其他项目中使用更新,这是无缝工作的。

代码语言:javascript
复制
repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    compile 'org.springframework.ldap:spring-ldap:1.3.1.RELEASE'
}

所以我很确定有一些我不知道的

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-08-08 10:11:21

spring工件是pom类型。要指定jar以外的任何工件,您需要指定类型。因此,您需要在pom中指定的工件是

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.1.RELEASE</version>
    <type>pom</type>
</dependency>

希望这能有所帮助

票数 2
EN

Stack Overflow用户

发布于 2014-08-08 11:02:15

正如@techbost所提到的,maven无法解析任何存储库中的spring 1.3.1.RELEASE.jar,因为这样的jar不存在。

让我们看看发生了什么。您可以通过以下方式定义依赖关系:

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.1.RELEASE</version>
</dependency>

如果不指定type标记,默认类型是jar。这意味着Maven试图点击这个URL来获取文件:http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar

如您所见,此文件不存在。这是因为spring-ldap模块没有jar,它是一个pom打包模块,这意味着它只有pom文件,它具有子模块的公共配置和这些子模块的定义。

接下来,您可能需要定义一个类型为pom

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.1.RELEASE</version>
    <type>pom</type>
</dependency>

人们可能会认为这是可行的,因为现在您指示maven下载一个pom文件,该文件确实存在:http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.pom

好吧,它也不起作用。这是因为pom工件不是真正的依赖项(只是为了提醒--依赖关系是为编译、测试和打包而添加到类路径中的文件,因此在类路径中有一个pom文件是没有意义的)。

你真正需要的是其中之一:

  • 使用spring的特定子模块,例如spring-ldap-core
  • 使用all分类器的spring-ldap模块。在本例中,您将把所有模块放在一个jar中。尽管它可能简化了您的配置,但它强烈地阻止了粒子。

在前一种情况下,您的依赖声明如下所示:

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap-core</artifactId>
    <version>1.3.1.RELEASE</version>
</dependency>

这个很管用。

在后一种情况下,您的依赖声明如下:

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.1.RELEASE</version>
    <classifier>all</classifier>
</dependency>

这也有效,虽然这是一个非常糟糕的主意。

P.S.mvn存储库站点不是真正的maven存储库。它是一个用于搜索和浏览maven-central中的工件的站点,并且在maven central没有搜索时是可用的。

我可以建议的两个存储库是:

  1. jcenter - Maven Central的超级集,默认情况下的https,发布者的web标识,更丰富的UI等等。有关更多细节,请参见https://bintray.com/bintray/jcenter (Set me up按钮将为您提供如何与Maven一起使用它的说明)
  2. Maven Central the https - 这里是Maven设置说明。
票数 1
EN

Stack Overflow用户

发布于 2014-08-08 09:52:40

我不认为您需要添加任何额外的存储库标记来获取spring工件。

您只需要在工件不属于默认maven回购时指定存储库,例如,对于Jboss https://repository.jboss.org/,您需要在pom中添加此存储库以获取该存储库的任何工件。

简单地在pom中添加下面的依赖项,它应该可以工作。

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.1.RELEASE</version>
</dependency>

在不指定存储库的情况下下载工件有任何问题吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25200511

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档