Graphic tutorial on getting started with Nexus

Source: Internet
Author: User
Tags maven central sonatype

Nexus Introduction

Nexus is the Maven Repository Manager. If you use Maven, you can download the required components (artifact) from the Maven central repository. However, this is generally not a good practice, you should set up a Maven repository server locally and maintain the local repository while maintaining the remote repository as a proxy to save bandwidth and time. Nexus can meet this requirement. In addition, he provides powerful warehouse management and component search functions. It is based on REST, and the friendly UI is an extjs REST client, which occupies less memory, based on a simple file system rather than a database. These advantages have increasingly become the most popular Maven Repository Manager.

Download and install

You can download the latest version of Nexus from the http://nexus.sonatype.org/downloads/, I use 1.3.0.

Nexus provides two installation methods: one is Jetty-embedded bundle, which can be run directly as long as you have a JRE. The second method is WAR. You only need to simply publish it to a web container.

 

Bundle Installation

ExtractNexus-webapp-1.3.0-bundle.zipTo any directory, suchD: \ dev_toolsAnd then open CMD and cd to the directory.D: \ dev_tools \ nexus-webapp-1.3.0 \ bin \ jsw \ windows-x86-32Run Nexus. bat. You will see the Nexus startup log, when you see "Started SelectChannelConnector@0.0.0.0: 8081", it indicates that Nexus Started successfully, then open the browser, access http: // 127.0.0.1: 8081/nexus, you will see the following page:

To stop Nexus, press Ctrl + C, and install Nexus. bat can be used to install Nexus into a windows service. Other scripts are used to start, stop, pause, resume, and uninstall the Nexus service.

 

WAR Installation

You need to have a web container that can run. Here, taking Tomcat as an example, add the installation directory of TomcatD: \ dev_tools \ apache-tomcat-6.0.18.First, we will downloadNexus-webapp-1.3.0.warRenameNexus. warAnd then copyD: \ dev_tools \ apache-tomcat-6.0.18 \ webapps \ nexus. warAnd then start CMD, cdD: \ dev_tools \ apache-tomcat-6.0.18 \ bin \Directory and run startup. bat. Everything is okay. Now you can open the browser to access http: // 127.0.0.1: 8080/nexus, and you will get the same interface.

 

Proxy external Maven Repository Login

To manage Nexus, log in as an administrator, click login in the upper-right corner of the page, and enter the default logon name and password: admin/admin123. After successful login, you will see a lot added in the left navigation bar:

Here, you can manage the repository, configure the Nexus system, manage tasks, manage users, roles, permissions, view the RSS source of the system, and manage and view system logs. You will see that Nexus has rich and powerful functions. In this article, I will only introduce some of the most basic management and operations.

 

Proxy Maven central repository

Click Repositories in the left-side Navigation Pane. the main panel of the interface displays a list of all the Repositories and warehouse groups. You can see that their Type field values include group, hosted, proxy, and virtual. Here we do not care about virtual. We only introduce the other three types:

  • Hosted, a local repository. We usually deploy our own components to this type of repository.
  • Proxy, which is used to represent a remote public repository, such as a maven central repository.
  • A repository group is used to merge multiple hosted/proxy repositories. We usually configure maven dependency repository groups.

From this we know that we need to configure a Maven Central repository proxy. In fact, Nexus has built-in Maven Central, but we need to do some configuration. Click Maven Central in the repository list and you will notice that its Policy is release. This indicates that it does not proxy the snapshot component of the remote repository. This is for some reason, the snapshot version components of the remote repository are unstable and not controlled by you. Using such components may pose potential risks. Then we found that there are three tabs under the main panel: Browse, Configuration and Mirrors. We click Configuration to configure. Now you need to care about two Configuration items: "Remote Storage Location" is the address of the Remote repository. For Maven Central, It is http://repo1.maven.org/maven2/##download Remote Indexes. As the name suggests, this field of Maven Central is False by default, this is to prevent a large number of Nexus servers from consuming the bandwidth of the central warehouse (the central warehouse has a large number of components and its index file is also large ). Here we need to set it to True and then click Save. After the central repository index file downloaded by Nexus, we can search all the components of the central repository locally. The configuration we just covered is shown as follows:

 

Add a proxy Repository

Here is another example. We want to proxy the public repository of Sonatype at http://repository.sonatype.org/content/groups/public /. Follow these steps: click Add on the top of the Repositories panel and select Proxy Repository. In the configuration section below, enter the following information: Repository ID-sonatype; Repository Name-Sonatype Repository; remote Storage Location-http://repository.sonatype.org/content/groups/public /. The remaining default values are Repository policies. We do not want to proxy the snapshot component because we have already described the cause. Click Save. The configuration page is as follows:

 

Manage local Maven Repositories

Nexus predefines three local warehouses: Releases, Snapshots, and 3rd Party. Each of these three warehouses has a specific purpose. Releases is used to deploy our own release components, Snapshots is used to deploy our own snapshot components, and 3rd Party is used to deploy third-Party components. some components, such as the JDBC driver of Oracle, we can't download it from a public repository, so we need to deploy it to our own repository.

Of course, you can also create your own local Repository. The procedure is similar to creating a proxy Repository. Click Add at the top of the Repository panel and select Hosted Repository, enter the id and name in the configuration panel below. Note that you do not need to enter the remote Repository address here. The Repository Type is the hosted that cannot be modified, and the Repository Policy, you can select Release or Snapshot as needed,

  • 1
  • 2
  • 3
  • Next Page

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.