Obtain dependency from Maven private server

Source: Internet
Author: User

It is the default configuration to directly obtain dependency packages from Maven public repository over the Internet. However, for Chinese software companies, access to these public warehouses is usually slow, which is even more impossible for software companies with strict management requirements that cannot directly access the internet. Maven projects can be configured to retrieve dependencies only from Maven private servers.

The previous article describes how to install nexus as a Maven private server. The following assumes that the Nexus service on the S1 server is used. Refer to the official documentation:

Http://www.sonatype.com/books/nexus-book/reference/config-sect-intro.html

There is a Maven project on the Development machine. Edit it first ~ /. M2/settings. xml.

<settings>  <mirrors>    <mirror>      <!--This sends everything else to /public -->      <id>nexus</id>      <mirrorOf>*</mirrorOf>      <url>http://S1:8081/nexus/content/groups/public</url>    </mirror>  </mirrors>  <profiles>    <profile>      <id>nexus</id>      <!--Enable snapshots for the built in central repo to direct -->      <!--all requests to nexus via the mirror -->      <repositories>        <repository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </repository>      </repositories>      <pluginRepositories>        <pluginRepository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </pluginRepository>      </pluginRepositories>    </profile>  </profiles>  <activeProfiles>    <!--make the profile active all the time -->    <activeProfile>nexus</activeProfile>  </activeProfiles></settings>

You only need to change S1 to your Nexus server address. If no custom repository exists in the Pom. xml file of your Maven project, you can use it. For example, run the MVN clean compile command to download the Pom. XML and jar packages from S1.

Note: Sometimes the latest snapshot has been deployed on nexus, but MVN clean compile does not take the latest version. In this case, you need to use the-u parameter to force the check.

MVN clean compile-u

If not, delete the local cache directory. In the Jenkins project, you can execute a command line before build, for example:

rm -rf /usr/share/tomcat7/.m2/repository/com/esri/carrier/nginx-factory/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.