开发者

Maven: Repository no longer exists! Now what?

I have just begun my journey in Maven2 and found the dependency repositories logic a little weird...

As far as I understand, I need to point Maven to a repository from which it can fetch the various POMs found in my dependencies. In other words, instead of downloading all the dependencies in my lib folder, as I did in the Ant era, I now have to look into various Maven repositories and, hopefully, find what I need.

OK, th开发者_运维问答anks to MVNBrowser things get a little easier. But! What if the Maven repository no longer exists?

For example, I use Slick in my project. Among the other dependencies, slick uses JNLP (for some reason). The artifact for jnlp is:

    <dependency>
        <groupId>javax.jnlp</groupId>
        <artifactId>jnlp</artifactId>
        <version>1.2</version>
    </dependency>

According to MVNBrowser, javax.jnlp can only be found in one repository, Freehep. Which is no longer available.

So now what?


This is excatly the reason why most Maven repositories refuse to let people update (or remove) existing versions and only allow bumping version numbers (or releasing under a new name). Regarding your dependency you will need to find another repository that contains it and then add this repository to your project (or super) pom like this:

<repositories>
    <repository>
      <id>java.net</id>
        <url>http://download.java.net/maven/2</url>
    </repository>
</repositories>

where you will have to replace the identifier and URL with the values for the new repo.

Alternativly maven actually first checks your own local repository to see if the package is already there (usually located in $HOME/.m2/ folder) so if you have the jar file at hand then you can install it with

mvn install:install-file -DgroupId=javax.jnlp -DartifactId=jnlp \ -Dversion=1.2 -Dpackaging=jar -Dfile=/path/to/jnlp-1.2.jar

Also note that mvnbrowser.com does not track content from all maven repositories, with the official Spring, Sun (Oracle) and JBoss (Redhat) repositories bring the most notable omissions. So the problems you describe actually occur pretty often (fx. when installing the Oracle JDBC driver) requiring you to go hunting for other repositories or adding the Jar to your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜