Deploy a local Maven project to Nexus Repository

Source: Internet
Author: User
Tags maven central

Deploy a local Maven project to Nexus Repository

Configure Nexus Repository

  1. Open the WEB Management Interface: http: // localhost: 8081/nexus/index.html
  2. Click Log In the upper right corner to Log on. Default Account: admin and password: admin123
  3. Click the Repositories item on the left-> central repository-> Configuration-> Download Remote Indexes = True-> Save to Download the index of the Remote repository.
  4. Right-click the central repository-> Update Index to Update the remote repository Index to the local location. This step can accelerate the local Index.
Note:
  • The new neuxs environment is just an empty repository and needs to be manually synchronized with the remote central database. By default, nexus disables remote index download. The most important thing is to enable remote index download. Find the three repositories Apache Snapshots, Codehaus Snapshots, and Maven Central in the repository list on the right, and then modify Download Remote Indexes to true without the repository configuration. Right-click the three repositories and select Repari Index. Then, Nexus downloads the remote Index file.Right-click the repository> Update Index to Update the remote repository Index to the local device. This step can accelerate the local Index..
  • Create a company's internal warehouse. The procedure is Repositories-> Add-> Hosted Repository. Enter the Repository ID and Repository Name in the lower part of the page. In addition, set Deployment Policy to Allow Redeploy.
  • The concept of repository group in Nexus is not available in Maven. In Maven's opinion, whether you are hosted or proxy or group, it is the same for me. I just follow the groupId, artifactId, version, and other information to ask you for components. To facilitate Maven configuration, Nexus can combine multiple repositories, hosted, or proxy into one group. In this way, Maven only needs to depend on one group, you can use all the repository content contained in the group.
Configure the Nexus Repository information in the project

Project pom file configuration distributionManagement (this can be copied directly from the Summary of Repository)

 


<DistributionManagement>

<Repository>

<Id> releases </id>

<Name> Nexus Release Repository </name>

<Url> http: // localhost: 8081/nexus/content/repositories/releases/</url>

</Repository>

<SnapshotRepository>

<Id> snapshots </id>

<Name> Nexus Snapshot Repository </name>

<Url> http: // localhost: 8081/nexus/content/repositories/snapshots/</url>

</SnapshotRepository>

</DistributionManagement>

Settings. xml: configure the account and password. Note that the server id and repository id must correspond

 

<Servers>
<Server>
<Id> releases </id>
<Username> admin </username>
<Password> admin123 </password>
</Server>
<Server>
<Id> snapshots </id>
<Username> admin </username>
<Password> admin123 </password>
</Server>
</Servers>

 

It is not good to write the username and password in plain text in the file. You can use the following method:
Step 1. First define a seed, windows test, settings-security.xml this file must be placed in the. m2 directory, otherwise will prompt not to find

 

Localhost $ mvn -- encrypt-master-password 123 asdadfafdadf
{BHe/qKN8q30HBG3bAGbYLOVLnAqVRkzjb9/7yWs + Ks0 =}

Vim ~ /. M2/settings-security.xml

<? Xml version = "1.0" encoding = "UTF-8"?>
<SettingsSecurity>
<Master> {BHe/qKN8q30HBG3bAGbYLOVLnAqVRkzjb9/7yWs + Ks0 =}</master>
</SettingsSecurity>

 

Step 2. Final generation

 

Mvn -- encrypt-password your password
{RxLx1asdfiafrjIHfXZDadfwveda23avsdv =}

Vim ~ /. M2/settings. xml

<Server>
<Id> internal </id>
<Username> 54 chen </username>
<Password> {RxLx1asdfiafrjIHfXZDadfwveda23avsdv =}</password>
</Server>

 

Mvn versions must be 2.1.0 or later.

Release to Nexus Repository

Command line format, run

Mvn deploy: deploy-file-Durl = http: // 192.168.0.4: 8081/nexus/content/repositories/thirdparty-DrepositoryId = thirdparty-Dfile = jmxspi. jar-DgroupId = Oracle. as-DartifactId = jmxspi-Dversion = 1.0-Dpackaging = jar-DgeneratePom = true

In Eclipse,

Create a new Maven Build,

The Base directory uses the project path as needed, for example, $ {workspace_loc: some-project}. In Gloals, enter deploy-Dmaven. test. skip = true and Run

To forcibly update maven repository, add a-U parameter, as shown in figure

Deploy-Dmaven. test. skip = true-U

 

Maven official guide _ Chinese full version clear PDF

Maven 3.1.0 release, Project Build Tool

Install Maven in Linux

Maven3.0 configuration and simple use

Set up sun-jdk and Maven2 in Ubuntu

Get started with Maven

This article permanently updates the link address:

Related Article

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.