Maven repository-Nexus environment setup and introduction, mavennexus

Source: Internet
Author: User
Tags maven central

Maven repository-Nexus environment setup and introduction, mavennexus
1. Environment setup 1.1 download

Http://www.sonatype.org/nexus/

Nexus oss [OSS = Open Source Software, Open Source Software-free]

Nexus professional-free trial [PROFESSIONAL version-paid].

Select NEXUS OSS

    


Find Download andInstall Nexus OSS. Download the ZIP file:

       

 

1.2 Configuration

Decompress the downloaded ZIP package to the following directory:

    


Add the bin directory of Nexus to the Path environment variable:

    


Associate Nexus with the current JDK and modify the following configuration file. The directory is,

$ {Nexus_HOME}/bin/jsw/conf/wrapper. conf. For example:

    


After the configuration is complete, you can access Nexus locally. If it appears, the configuration is successful:

    


2. warehouses in Nexus
2.1 Type Introduction

Log on to Nexus and select Repositories in the left-side menu bar. Then, the screen on the right is displayed. The upper part on the right is the repository column, and the blacklist is the repository column of the group type.

The following describes the repository types:

Ø hosted: local repository. We usually deploy our own components to this type of repository. For example, the company's second-party library.

Proxies are used to represent remote public repositories, such as maven central repository.

Ø group, a repository group, used to merge multiple hosted/proxy repositories. When your project wants to use resources in multiple repository, it does not need to be referenced multiple times, you only need to reference a group.

    


2.2 Manage local warehouses

As mentioned above, the local repository type is hosted, and the Nexus predefines three local warehouses: Releases, Snapshots, and 3rd Party. let's talk about what these three preset warehouses are:

Releases:

Here we store the build released in our own project, usually the Release version. For example, we have made an FTP Server project, and the generated component is ftpserver. war, we can release this build to the local Releases repository of Nexus. this article will be introduced later.

Snapshots:

This repository is very useful. It aims to allow us to release non-release versions and non-stable versions. For example, we develop a project under trunk, before official release, you may need to temporarily release a version for your peers, because your peers are dependent on your module development, at this time, we can release the Snapshot version to this warehouse, and your companions can use simple commands to obtain and use this temporary version.

3rd Party:

As the name suggests, you may ask if a central warehouse is used to manage a third-party library. That's right. Here, you can add your own third-party library, for example, some components do not exist in the central repository. for example, if you cannot find the Oracle JDBC driver in the central warehouse, you need to add it to the 3rdparty warehouse by yourself.


2.3 manually create a separate database for your project on Nexus

Create a database, Add --> HostedRepository

    


Create permission

    


Create a role (specify permissions)

    


User Creation (specified role)

    


2.4 Maven repository Group

We can see from the previous introduction that we can create multiple proxy repositories and hosted Local repositories. If there is no concept of a repository group, if we need to reference these repositories, we need to add them to our setting. in xml, with the concept of a repository group, we only need to make one reference and add the required repository to the repository group. For example:

    


By default, a repository group contains the local repository Releases, snapshots, 3rd party, and Agent repository MavenCentral. you can add a repository to this repository group on the Configuration page. if you want to create a Repository Group, select add --> Repository Group in the Repositories menu.


3. Configure the Nexus repository in the project

If there is only one project, you can configure it in the project's pom file:

  


If you have multiple projects that use the Nexus configuration, you can put the Settings file of Maven as an echo:

  


4. Configure the repository Image

By default, if no dependent component is found in the local repository, go to Nexus first when necessary. If the Nexus service is disabled, it is automatically found in the central repository.

If we want to overwrite the default address of the central repository, all the items on which the dependency is mandatory will be found in Nexus. Even if Nexus is disabled, it will not be downloaded from the central Factory:

Modify the Settings file of Maven:

  


Note: if there is something in the local repository but not in Nexus, You need to test it in the Nexus repository and then update the repository index:

  

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.