[英]Maven repo does not work
我正在嘗試添加maven存儲庫mvnrepository.com
,但似乎我沒有這樣做。
<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構建輸出報告我不是
正在下載: http : //mvnrepository.com/artifact//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO]無法找到資源'org。 springframework.ldap:spring-ldap:jar:存儲庫mvnrepository中的1.3.1.RELEASE'( http://mvnrepository.com/artifact/ )
我究竟做錯了什么? 我該如何下載spring ldap artifact?
更新我嘗試了幾個工件,但都失敗了
正在下載: http : //repo1.maven.org/maven2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO]無法找到資源' org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE'在存儲庫maven central repo中( 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 [INFO]無法找到資源'org.springframework.ldap:spring-ldap:jar :存儲庫java.net repo中的1.3.1.RELEASE'( 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 [INFO]無法在存儲庫彈簧中找到資源'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE'外部( http://maven.springframework.org/external/ )下載: http : //search.maven.org//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3。 1.RELEASE.jar [INFO]無法 在資源庫repo.jenkins-ci.org( http://search.maven.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 [INFO]無法找到資源'org.springframework.ldap:spring-ldap: jar:存儲庫mvnrepository中的1.3.1.RELEASE'( https://repository.jboss.org/ )下載: http ://repo1.maven.org/maven2//org/springframework/ldap/spring-ldap/1.3 。 1.RELEASE / spring-ldap-1.3.1.RELEASE.jar [INFO]無法在資源庫中心找到資源'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE'( http:// repo1 .maven.org / maven2 / )
如果我沒有在settings.xml中定義任何存儲庫,那么響應如下:
正在下載: http : //repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO]無法找到資源'org .springframework.ldap:spring-ldap:jar:1.3.1.RELEASE'在存儲庫中心( http://repo1.maven.org/maven2 )
更新此外,我在其他項目中使用gradle,這無縫地工作
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'org.springframework.ldap:spring-ldap:1.3.1.RELEASE'
}
所以我很確定有一些我不知道的maven回購
spring-ldap工件是pom類型。 要指定jar以外的任何工件,您需要指定類型。 所以你需要在你的pom中指定的工件是
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
<type>pom</type>
</dependency>
希望這可以幫助
正如@techbost所提到的,maven無法從任何存儲庫解析spring-ldap-1.3.1.RELEASE.jar,因為這樣的jar不存在。
讓我們看看發生了什么。 您可以通過以下方式定義依賴項:
<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
:
<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/彈簧LDAP的1.3.1.RELEASE.pom
好吧,它也行不通。 這是因為pom
artifact不是真正的依賴項(僅用於提醒 - 依賴項是添加到類路徑中以進行編譯,測試和打包的文件,因此在classpath中有一個pom文件是沒有意義的)。
你真正需要的是兩者中的一個:
spring-ldap-core
。 spring-ldap
模塊的all
分類。 在這種情況下,您將把所有模塊放在一個罐子里。 雖然它可能會減輕您的配置,但強烈建議不要使用粒子。 在前一種情況下,您的依賴聲明將如下所示:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
這有效。
在后一種情況下,您的依賴聲明將如下所示:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
<classifier>all</classifier>
</dependency>
這也很有用,雖然這真的很糟糕。
PS mvnrepository站點不是真正的 maven存儲庫。 它是一個在maven-central中搜索和瀏覽工件的站點,當maven central沒有搜索時可以使用它。
我建議的兩個存儲庫是:
jcenter
- Maven Central的超集,默認情況下為https,發布者的網絡身份,更豐富的用戶界面等。有關詳細信息,請參閱https://bintray.com/bintray/jcenter(Set Set me up
按鈕將為您提供有關如何使用的說明它與Maven) 我認為您不需要添加任何額外的存儲庫標記來獲取spring-ldap工件。
您只需要在工件不屬於默認maven存儲庫時指定存儲庫,例如,Jboss存儲庫https://repository.jboss.org/ ,您需要在pom中添加此存儲庫以獲取此存儲庫的任何工件。
你簡單地在你的pom中添加以下依賴項,它應該工作。
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
在沒有指定存儲庫的情況下下載工件有任何問題嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.