Reputation: 2251
I am trying to add a maven repository mvnrepository.com
, but it seems that I fail doing this.
<repository>
<id>mvnrepository</id>
<url>http://mvnrepository.com/artifact/</url>
</repository>
I can clearly see that the artifact I am looking for is there http://mvnrepository.com/artifact/org.springframework.ldap/spring-ldap/1.3.1.RELEASE
But my maven build output reports me that it's not
Downloading: http://mvnrepository.com/artifact//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository mvnrepository (http://mvnrepository.com/artifact/)
What am I doing wrong? How can I download spring ldap artifact?
UPDATE I have tried several artifactories, but all of them fail
Downloading: http://repo1.maven.org/maven2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository maven central repo (http://repo1.maven.org/maven2/) Downloading: http://download.java.net/maven/2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository java.net repo (http://download.java.net/maven/2/) Downloading: http://maven.springframework.org/external//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository spring external (http://maven.springframework.org/external/) Downloading: http://search.maven.org//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository repo.jenkins-ci.org (http://search.maven.org/) Downloading: https://repository.jboss.org//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository mvnrepository (https://repository.jboss.org/) Downloading: http://repo1.maven.org/maven2//org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository central (http://repo1.maven.org/maven2/)
If I do not define any repositories in settings.xml, then the response is the following:
Downloading: http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar [INFO] Unable to find resource 'org.springframework.ldap:spring-ldap:jar:1.3.1.RELEASE' in repository central (http://repo1.maven.org/maven2)
UPDATE Besides, I use gradle in other projects, and this works seamlessly
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'org.springframework.ldap:spring-ldap:1.3.1.RELEASE'
}
So I am pretty sure there is some maven repo I don't know about
Upvotes: 1
Views: 3112
Reputation: 22893
As @techbost mentioned, maven can't resolve spring-ldap-1.3.1.RELEASE.jar from any repository, because such jar does not exist.
Let's see what's going on. You define your dependency in the following way:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
If you don't specify a type
tag, the default type is jar
. Which means that Maven tries to hit this URL to get the file:
http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.jar
As you see, this file does not exist. That's because the spring-ldap
module does not have a jar, it's a pom
packaging module, which means it only has pom file, which has common configuration for submodules and definition of those submodules.
Next you might want to define a type to be pom
:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
<type>pom</type>
</dependency>
One might think that should work, because now you instruct maven to download a pom file, which does exist: http://repo1.maven.org/maven2/org/springframework/ldap/spring-ldap/1.3.1.RELEASE/spring-ldap-1.3.1.RELEASE.pom
Well, it won't work as well. That's because pom
artifact is not a real dependency (just for reminder - dependencies are files that added to your classpath for compilation, testing and packaging, so it makes no sense to have a pom file in classpath).
What you actually need is one of the two:
spring-ldap-core
.all
classifer of spring-ldap
module. In this case you'll bring all the modules, in a single jar. Although it might ease your configuration, it's strongly discouraged particle. In the former case, your dependency declaration will look like:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
This works.
In the later case your dependency declaration will be as following:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
<classifier>all</classifier>
</dependency>
This works as well, although it's really bad idea.
P.S. mvnrepository site is not a real maven repository. It's a site for searching and browsing artifacts in maven-central and was usable when maven central didn't have search.
The two repositories I can suggest are:
jcenter
- superset of Maven Central, https by default, web identity of the publishers, richer UI, etc. See https://bintray.com/bintray/jcenter for more details (Set me up
button will give you instructions on how to use it with Maven)Upvotes: 1
Reputation: 608
The spring-ldap artifact is pom type. To specify any artifact other than jar you need to specify the type. So the artifact you need to specify in your pom is
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
<type>pom</type>
</dependency>
Hope this helps
Upvotes: 2
Reputation: 608
I don't think you need to add any extra repository tag to fetch spring-ldap artifact.
You only need to specify the repository when the artifact doesn't belong to the default maven repo for e.g., Jboss Repository https://repository.jboss.org/, you need to add this in your pom to fetch any artifact of this repository.
you simple add below dependency in your pom and it should work.
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
Are you having any problem in downloading artifact without specifying repository?
Upvotes: 0