Maven remote repository
In this section, you will learn to utilize remote repository of Maven for downloading libraries which are not present in Maven's central repository.
What is Maven remote repository ?
All dependency libraries are downloaded by the maven from the Maven central repository. But some libraries are still not included in the Maven central repository. In that case, you need to add Maven remote repository.
For example, org.jboss.seam library is not available at Maven
central repository but this library is available at Maven remote
repository which is http://repository.jboss.org/nexus/content/groups/public/
The dependency for org.jboss.seam library is given below :
<dependency> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam</artifactId> <version>2.2.0.GA</version> </dependency>
If you try to install it using mvn install
, it will show the following error on console :
C:\project-maven\roseindia-webapp>mvn install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building roseindia-webapp Maven Webapp [INFO] task-segment: [install] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource Downloading: http://repo1.maven.org/maven2/org/jboss/seam/jboss-seam/2.2.0.GA/jb oss-seam-2.2.0.GA.pom [INFO] Unable to find resource 'org.jboss.seam:jboss-seam:pom:2.2.0.GA' in repos itory central (http://repo1.maven.org/maven2) Downloading: http://repo1.maven.org/maven2/org/jboss/seam/jboss-seam/2.2.0.GA/jb oss-seam-2.2.0.GA.jar [INFO] Unable to find resource 'org.jboss.seam:jboss-seam:jar:2.2.0.GA' in repos itory central (http://repo1.maven.org/maven2) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) org.jboss.seam:jboss-seam:jar:2.2.0.GA Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=org.jboss.seam -DartifactId=jboss-seam -Dversion=2.2.0.GA -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.jboss.seam -DartifactId=jboss-seam -D version=2.2.0.GA -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId =[id] Path to dependency: 1) net.roseindia:roseindia-webapp:war:1 2) org.jboss.seam:jboss-seam:jar:2.2.0.GA ---------- 1 required artifact is missing. for artifact: net.roseindia:roseindia-webapp:war:1 from the specified remote repositories: central (http://repo1.maven.org/maven2) [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Wed Jul 11 16:44:12 IST 2012 [INFO] Final Memory: 7M/18M [INFO] ------------------------------------------------------------------------ |
You can fix the above error by adding remote repository in your Maven?s pom.xml file like this :
<repositories> <repository> <id>JBoss repository</id> <url>http://repository.jboss.org/nexus/content/groups/public/</url> </repository> </repositories>