How to add remote repository in Maven

Not every library is stored in the Maven Central Repository, some libraries are only available in Java.net or JBoss repository (remote repository).

1. Java.net Repository

pom.xml

  <repositories>
        <repository>
            <id>java-net-repo</id>
            <url>https://maven.java.net/content/repositories/public/</url>
        </repository>     
  </repositories>

2. JBoss Repository

pom.xml

  <repositories>
        <repository>
            <id>jboss-repo</id>
            <url>http://repository.jboss.org/nexus/content/groups/public/</url>
        </repository>
  </repositories>

3. Spring Repository

pom.xml

  <repositories>
        <repository>
            <id>spring-repo</id>
            <url>https://repo.spring.io/release</url>
        </repository>
  </repositories>

References

  1. Configuring Maven to use the JBoss Repository
  2. Spring Repository

30 comments on “How to add remote repository in Maven

  1. Hello,

    What about a private remote repositoy with user and password? Something like :
    a. Repository id: fake-repo
    b. URL: http://myfakemaven.repo.com
    c. User: dev
    d. Password: dev-password

    Reply
  2. Hi
    Based on profile how i can give the repository (custom repo url)

    Reply
  3. Hello mykong,

    i am trying to compile saiku 2.5 tool on netbeans

    when i right click the project and click on clean and build it is giving following error.

    BUILD FAILURE

    ————————————————————————

    Total time: 9:14.264s

    Finished at: Fri Aug 07 18:10:08 IST 2015

    Final Memory: 5M/15M

    ————————————————————————

    Failed to execute goal on project saiku-service: Could not resolve dependencies for project org.saiku:saiku-service:jar:2.5: Failed to collect dependencies for [org.olap4j:olap4j:jar:1.2.0-SNAPSHOT (compile), org.apache.poi:poi:jar:3.7 (compile), org.apache.poi:poi-ooxml:jar:3.7 (compile), eigenbase:eigenbase-properties:jar:1.1.0.10924 (compile), eigenbase:eigenbase-resgen:jar:1.3.0.11873 (compile), eigenbase:eigenbase-xom:jar:1.3.0.11999 (compile), org.jdom:jdom:jar:1.1 (compile), org.slf4j:slf4j-log4j12:jar:1.6.4 (compile), org.slf4j:slf4j-api:jar:1.6.4 (compile), log4j:log4j:jar:1.2.14 (compile), junit:junit:jar:4.10 (compile), hsqldb:hsqldb:jar:1.8.0.10 (compile), pentaho:mondrian:jar:3.5.7 (compile), commons-lang:commons-lang:jar:2.2 (compile), javax.servlet:javax.servlet-api:jar:3.1.0 (compile), org.apache.commons:commons-io:jar:1.3.2 (compile), commons-vfs:commons-vfs:jar:1.0 (compile)]: Failed to read artifact descriptor for org.olap4j:olap4j:jar:1.2.0-SNAPSHOT: Could not transfer artifact org.olap4j:olap4j:pom:1.2.0-SNAPSHOT from/to pentaho-third-party (http://repo.pentaho.org/artifactory/third-party/): Failed to transfer file: http://repo.pentaho.org/artifactory/third-party/org/olap4j/olap4j/1.2.0-SNAPSHOT/olap4j-1.2.0-SNAPSHOT.pom. Return code is: 503, ReasonPhrase: Service Temporarily Unavailable. -> [Help 1]

    To see the full stack trace of the errors, re-run Maven with the -e switch.

    Re-run Maven using the -X switch to enable full debug logging.

    For more information about the errors and possible solutions, please read the following articles:

    [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

    What should i do to fix this issue please help me out.

    my pom.xml is

    saiku-core

    org.saiku

    2.5

    4.0.0

    org.saiku

    saiku-service

    2.5

    saiku – services

    org.apache.maven.plugins

    maven-antrun-plugin

    1.2

    create-package

    test-compile

    run

    org.apache.maven.plugins

    maven-compiler-plugin

    2.0.2

    ${maven.compiler.source}

    ${maven.compiler.target}

    UTF-8

    org.apache.maven.plugins

    maven-resources-plugin

    2.3

    UTF-8

    org.olap4j

    olap4j

    1.2.0-SNAPSHOT

    asm

    asm

    asm

    asm-commons

    retroweaver

    retroweaver

    retroweaver

    retroweaver-rt

    org.apache.poi

    poi

    3.7

    org.apache.poi

    poi-ooxml

    3.7

    eigenbase

    eigenbase-properties

    1.1.0.10924

    eigenbase

    eigenbase-resgen

    1.3.0.11873

    eigenbase

    eigenbase-xom

    1.3.0.11999

    org.olap4j

    olap4j-xmla

    1.2.0-SNAPSHOT

    org.jdom

    jdom

    1.1

    org.slf4j

    slf4j-log4j12

    ${slf4j.version}

    org.slf4j

    slf4j-api

    ${slf4j.version}

    log4j

    log4j

    1.2.14

    junit

    junit

    4.10

    hsqldb

    hsqldb

    1.8.0.10

    pentaho

    mondrian

    3.5.7

    commons-lang

    commons-lang

    2.2

    javax.servlet

    javax.servlet-api

    3.1.0

    org.apache.commons

    commons-io

    1.3.2

    commons-vfs

    commons-vfs

    1.0

    Central-One

    http://repo1.maven.org/maven2

    Central-Two

    http://uk.maven.org/maven2

    Central-Three

    http://mirrors.ibiblio.org/pub/mirrors/maven2

    Central-Four

    http://maven.antelink.com/content/repositories/central/

    MY settings.xml is

    uk

    central

    http://uk.maven.org/maven2/

    *

    Reply
  4. Hi,

    Is there way to define my pom.xml to download multiple dependency plugin.

    Eg: if in my pom.xml when i try to download x.y.z_version.jar in the dependencies list, it must download a.b.c_versions.jar file. Vice versa is not required. Can you provide the pom scenario for this.

    Reply
  5. HI MkYong,
    Thanks for the article.

    Is it possible to mix and match multiple repos in a single pom, ie fetch some jars from our artifactory repo, and some from local file system, for instance..

    Reply
  6. Thanks Mkyong for saving my day! you are great man!

    Reply
  7. Hi, i have a one jar in my local repositiry(system1),and my friend want to access my jar in his project(system2) by using maven can any one please help me.

    Reply
  8. Everytime I read your articles I feel much like your writting is improving, see it from your day one.

    Reply
  9. Hello, as per my project requirement, I have one war file core-web.war at my local I want to add it as a dependency or repository to my maven project & then, so all the services n classes of that war file will be available to the maven project. Please suggest the solutions …

    Reply
  10. Hi Mkyong, am new to maven and find your site very helpful, so thank you and please don’t stop what you are doing. I wanted to find out, where can I find a list of repositories to add to my POM.xml? I have a lot of dependencies but do not know were to find the repositories for these dependencies. Any assistance will be appreciated. Thank you

    Reply
  11. Hi, I think we can also make this generic by adding it to settings.xml (under home/.m2).
    Is that correct? Thanks.

    Reply
  12. Hi Mkyong,

    Where is pom.xml you described is located? I cannot understand where to configure remote repos 🙁

    Reply
  13. It would be better article if you would have specified the POM.XML location also. Nowhere it is mentioned!!!

    Reply
  14. Hi Mkyong,

    Superb article. I want to know where can i get all the maven remote repositories link.

    Reply
    1. No, you don’t, and not necessary, every1 is able to host a remote repository server.

      Reply
      1. This is absolutely true that “every1 is able to host a remote repository server.” but similar to Jboss application server, do we have remote repositories for other application server also. e.g. IBM Web Application Server.
        Where can we search for that?

        Reply
  15. Hi Mkyong,
    I want to know that attribute value is java.net ,it is fixed or its any logical name,If it is fixed what is the reason behind this?

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *