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

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
21 Comment threads
8 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
23 Comment authors
Jason Rembertpankaj jangirMateensamAtul Prasad Recent comment authors
newest oldest most voted
veeru
Guest
veeru

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.

Jason Rembert
Guest
Jason Rembert

you can download the files directly incl dependencies from a remote repository on this site: http://jar-download.com/maven-dependency-from-remote-repository.php

pankaj jangir
Guest
pankaj jangir

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)]:… Read more »

sam
Guest
sam

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.

Atul Prasad
Guest
Atul Prasad

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..

shev_lev
Guest
shev_lev

What if I need to provide username and password?

Dittmar
Guest
Dittmar

See “Consuming artifacts deployed in a Bitbucket repository”
https://synergian.github.io/wagon-git/bitbucket.html

Note the “Maven 2.2.1 Workaround for HTTP Basic auth”

which I needed even I use Maven 3.2.3!

Alonso Isidoro Roman
Guest
Alonso Isidoro Roman

Thanks Mkyong for saving my day! you are great man!

someone
Guest
someone

HI MyKong ,why you dont reply to people?

Pat Moore
Guest
Pat Moore

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

10288r
Guest
10288r

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 …

trackback
How to download from Maven remote repository?

[…] How To Add Remote Repository In Maven Tags : maven maven-faq maven-repo mkyong Founder of Mkyong.com, love Java and open source stuffs. Follow him on Twitter, or befriend him on Facebook or Google Plus. […]

junior
Guest
junior

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

Madhu
Guest
Madhu

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

Jugal Thakkar
Guest
Jugal Thakkar

Hello, Madhu

You can Make it generic by creating a Profile into settings.xml
see this Link from Maven Docs
http://maven.apache.org/guides/mini/guide-multiple-repositories.html

Dragon
Guest
Dragon

Hi Mkyong,

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

RoarLion
Guest
RoarLion

it will be created when you create a standard project using maven ..

see here for details..
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

sHAILU
Guest
sHAILU

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

RoarLion
Guest
trackback
UCOSP Week 1 | Jason's UCOSP Blog

[…] Maven – Nexus interaction: Add Repo to Maven project:¬†http://www.mkyong.com/maven/how-to-add-remote-repository-in-maven-pom-xml/ […]

Thiago Pellison
Guest
Thiago Pellison

Thanks mkyong, it solved me a problem when deploying JBoss 5.1.0GA.

Regards,

Thiago

Pratik Jain
Guest
Pratik Jain

Hi Mkyong,

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

Siddhanta Kumar Pattnaik
Guest
Siddhanta Kumar Pattnaik

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?

trackback
Maven Tutorials

[…] is Maven remote repository, and how to configure it Not all libraries are store in Maven central repository, often times, you need to add some remote […]

Mateen
Guest
Mateen

Hi thanks for the tutorial