Create a Maven local repository;

Source: Internet
Author: User

When you add dependency packages in POM. XML, sometimes you will be prompted that you cannot get from the http://repo1.maven.org/maven2/, then you can configure a local repository;

Download the Nexus war package of the maven repository website source code package from the Internet and put it under the webapps directory of the tomcat installation directory. We recommend that you download a single-host version of Tomcat and configure an unused port, this can be used with the development environment;

Start Tomcat and wait for a while. You may need to download some plug-ins in the Tomcat input log. After running the plug-in, open the website: http: // 127.0.0.1: 8090/nexus, it is shown as follows (Tomcat is queried ):

When the website runs normally, we can use the Nexus local repository we created normally;

Open Pom. XML to configure the repository we want to use:

<! -- After creating Maven, the prompt Org. apache. maven cannot parse, similar instructions cannot get from http://repo1.maven.org/maven2, you need to configure the local repository --> <repositories> <repository> <ID> ishitong-local-Maven </ID> <Name> ishitong localmaven </Name> <URL> HTTP: // 127.0.0.1: 8090/nexus/content/repositories/mirrors/</URL> <releases> <enabled> true </enabled> </releases> <snapshots> <enabled> false </enabled> </snapshots> </Repository> </repositories> <pluginrepositories> <Pluginrepository> <ID> ishitong-local-Maven </ID> <Name> ishitong localmaven </Name> <URL> http: // 127.0.0.1: 8090/nexus/content/repositories/mirrors/</URL> <releases> <enabled> true </enabled> </releases> <snapshots> <enabled> false </enabled> </snapshots> </pluginrepository> </pluginrepositories> <! -- Upload the component to the local repository when running MVN deploy --> <distributionmanagement> <repository> <ID> nexus-releases </ID> <Name> nexus release repository </Name> <URL> HTTP: // 127.0.0.1: 8090/nexus/content/repositories/releases/</URL> </Repository> <snapshotrepository> <ID> nexus-snapshots </ID> <Name> nexus snapshot repository </Name> <URL> HTTP: // 127.0.0.1: 8090/nexus/content/repositories/snapshots/</URL> </snapshotrepository> </distributionmanagement>

I put the preceding statement after the </Properties> node;

In the future, if you want to add a new dependency package in POM. XML, the repository configured here will be searched and downloaded;

To create a local nexus repository website, you can add some custom. Jar packages here:

First, log on to nexus. The default username and password are admin and admin123. There is a "log in" button in the upper-right corner of the page. After the logon is successful, several more main menus will be loaded on the Left bar;

Click the Repositories page under views/respositories:

In the repository list on the right-side main interface, select a repository, for example, releases. Click this repository. The releases section appears in the list. We need to upload the custom jar dependency information for configuration, click the artiface upload label;

You can know from Gav definition that there are two cell-based methods. If the POM method is used, it is the configured jar information, for Gav parameters, You need to configure group, artiface, version, and packaging information by yourself.

Select artifact (s) to upload is the region where the JAR file is uploaded. Click Add artiface in the region to add the uploaded JAR file to the artifacts box below;

Finally, click the "Upload artiface (s)" button below to save the dependent information and files;

For example, we add a dependency package whose artiface is ABC. jar;

GROUP: abcjar

Artiface: ABC. Jar

Version: 1.0.0

Packaging: jar

Use select artifact (s) to upload to select the XXX. jar file that you want to add locally;

Add the Add artiface button:

Finally, click "Upload artiface (s)" to save the custom dependency package information;

In this case, you can query the custom package we added through the group or artiface information. Search: abcjar through artiface search in the right column, and the right interface appears:

We can directly paste the XML content on the right to Pom. XML for use;

 

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.