Use Nexus to create a

Source: Internet
Author: User
Tags nexus hosting maven central sonatype

The deployment environment is windowsxp

First download the latest version of Nexus from Http://nexus.sonatype.rog/downloads

We can download it according to individual needs. There are nexus-webapp-1.9.2.3-bundle.zip and other systems running compressed files or war packet Nexus-webapp-1.9.2.3.war.

The Nexus-webapp-1.9.2.3-bundle.zip bag comes with a jetty container, so we don't have to find another container, so we can start the operation directly.

Bundle Installation Method:

Home Extract Bundle file, this time back to get two subdirectories:

nexus-oss-webapp-1.9.2.3 The directory contains the files needed to run the nexus, such as startup scripts, dependency jar packages, and so on.

Sonatype-work The directory contains the nexus generated configuration, log files, warehouse files, and so on. The first directory is required to run the Nexus, and all of the same version of Nexus Power contains the same contents. While the second directory is not required, the Nexus will dynamically create the directory while it is running, but his content is different for each Nexus instance, since the nexus used by different users on different machines will have various configurations and warehouse content. When the user needs this nexus, the default backup sonatype-work/directory, because the directory contains user-specific content, and the contents of the nexus-webapp1.9.2.3 directory can be obtained directly from the installation package.

If you want to start the Nexus need to select the corresponding system version under Nexus-oss-webapp-1.9.2.3\bin\jsw\, my environment is: windows-x86-32, so choose this directory there are some scripts as follows:
Installnexus.bat installing Nexus as a Windows service

Uninstallnexus.bat Uninstalling the Nexus Windows service

Startnexus.bat Start Nexus Windows Service

Stopnexus.bat Stop Nexus WinDOS Service

Pausenexus.bat Pause Nexus Windows service

Resumenexus.bat resuming a paused Nexus WinDOS service

If I don't want to use these scripts every time I start, I can configure the Widnwos service to boot automatically.

It is also very convenient to start a nexus on a Linux system, such as a Unbuntu 32-bit system, so just go to nexus-oss-webapp-1.9.2.3\bin\jsw\linux-x86-32 and run the following command:

$./nexus Console

At this point, you can see the command line output that starts, you can use Ctril+c to stop the Nexus

In addition to the console, the Nexus Linux script provides the following commands:

./nexus Start: Start Nexus service in the background

./nexus STOP: Stop the Nexus service in the background

./nexus Status: View background Nexus Service status

./nexus Restart: Restart the backend Nexus service

The port number used by the Nexus Bundle by default is: 8081, if the boot service can access:

Http://localhost:8081/nexus

A port conflict may occur when you start the bundle, or you can open it when you want to follow a port change: nexus-oss-webapp-1.9.2.3\conf\plexus.properties file found in the properties: Application-port Change to the appropriate port according to your needs. I changed it to 4040.

At this time, the address should be the same when visiting: Http://localhost:4040/nexus

War Way to install Nexus

The war package supports mainstream web containers such as Tomcat, Classfish, jetty, and resin

For example, Tomcat, put the downloaded war in the WebApps directory and then run Tomcat, specifically look at the Tomcat data

Sign in to Nexus

Nexus default Administrator username and password: admin/admin123

Nexus built-in warehouse introduction

Maven Gentral: This brutal agent maven central Repository, whose policy is release, will only download and cache the release builds in the central repository.

Release: This is a host-type warehouse where the policy is release, which is used to deploy the release build artifacts within the organization.

Snapshots: This is a host-type warehouse with a policy of snapshot, which is used to deploy snapshot version artifacts within the organization.

3rd party: This is a host-type warehouse with policy release, which is used to deploy components that cannot be obtained from a public warehouse.

Apache Snapshots: This is a Snapshot Agent repository that is used to proxy the snapshot version artifacts of the Apache Maven repository.

Codehaus snapshots: This is a broker repository with policy snapshot that is used to proxy the snapshot version artifacts for Codehaus maven repositories.

Google code: This is a policy release agent repository that is used to proxy the Google Code maven warehouse release build widget.

java.net Maven2: This is a broker repository with policy release, used to proxy the release builds of the java.net maven repository

Public repositories: The Warehouse group aggregates all the above-mentioned policies as release warehouses and provides services through a consistent address

Public Snapshot repositories: The Warehouse group aggregates all of the above policies into Snapshot warehouses and provides services through a consistent address. (This is not available in the nexus-oss-webapp-1.9.2.3 version)

Nexus Warehouse Classification Concept

Maven can download artifacts directly from the host repository, and Maven can also download artifacts from the agent repository, while the agent repository downloads and caches the artifacts indirectly from the remote repository, and finally, for convenience, maven can download artifacts from the Warehouse group, and the Warehouse group has no actual content. It will go to the host repository or the agent repository that it contains to get the content of the city-level artifacts.

Create a Nexus Hosting Warehouse

Create a hosting warehouse first click the repositories link in the left navigation bar of the interface, select Add in the right panel, and then select hosted Repository in the drop-down menu to see the configuration interface as follows:

Fill in the warehouse ID repostory ID and warehouse name Repository name and warehouse type Respository type warehouse format Provider Select default Maven2 Repository, then Repository Pol Icy readers can configure whether the repository is a release build artifact warehouse or a snapshot version component repository, depending on their needs. Defualt Local Storage location indicates that the warehouse does not have a People store directory, the value of this field is empty, when the warehouse is created, the value becomes a file path based on sonatype-work, such as : E:\ Nexus-oss-webapp-1.9.2.3-bundle\sonatype-work\nexus\storage

The default address warehouse store directory address.

In the Access Setting group

The Deployment policy is used to configure the deployment strategy for the warehouse, with options for read-only (prohibit deployment), to turn off redeployment (the same artifact can be deployed only once), and to allow redeployment.

Allow file browsing indicates whether the content of the warehouse is allowed to browse

Include in search indicates whether the warehouse is indexed and provides a search

The Publish URL is used to control whether the service is serviced through a URL, and if you choose False, you get HTTP404 not Found error when you access the address of the warehouse

The not Found cache TTL indicates the time when a file has not been found to cache this non-existent information. Take the default value of 1440 minutes for example, if a file does not exist, then in the next 1440 minutes, if the Nexus again get the file request, it will directly return the non-existent information, and will not find the system.

Create Nexus Agent Warehouse

Similar to the creation of the hosting warehouse, the value of the primary repository Type is changed to proxy when you see the following:

For the Agent warehouse, the most important thing is that the remote warehouse address is

Remote Storage location, the user must enter a valid value

Download remote Indexes Indicates whether to download the index of the repository

Checksum policy configures policies when checking for errors, and users can choose to ignore, log warning messages, or reject the download.

Authentication when the remote repository needs authentication here, the authentication configuration will be useful.

The Artifact Max Age component caches the longest time, and for snapshot versions, the default value of Artifact Max is 1, which means that the widget has been saved since it was stored, not re-downloaded, and the default value for the snapshot version is 1440 minutes for every

Metadata Max Age Warehouse metadata file cache maximum time

HTTP request Setting and Override HTTP proxy Setting where the former is used to configure the Nexus to access the remote repository when the HTTP requests parameters, which are used to configure the HTTP proxy

Create a Nexus Warehouse Group

Create a warehouse group the same step as other steps is to select the repository group in the drop-down box when you select Add to see the following:

The information in the configuration is the same as others, there is no release and snapshot in the Warehouse group, which differs from the host warehouse and the Agent warehouse. In the configuration interface, you can select warehouses in the Nexus, aggregate them into a virtual warehouse group, and note that the order of warehouses that the warehouse group contains determines the order in which the warehouse groups facilitate the warehouses they contain, so it is best to put the usual warehouses in front, and when users download the artifacts from the Warehouse group, can be accessed quickly to the repository containing the artifacts.

Nexus Index and Widget search

To search the MAVEN Central Library, you first need to set up the MAVEN Center agent repository in the Nexus to download remote indexes such as:

Download Remote Indexes Property set to True defaults to False

True is on, false is off because the central warehouse content is relatively large, so its index file is larger, need to see how the download, we can click the Scheduled Tasks link in the left navigation bar of the interface, we can see the system scheduled task whose status is runing, Say oh because after the download is complete, the task disappears.

Scheduled Tasks Interface:

Configure MAVEN to download widgets from Nexus

When you need to add a public warehouse on a nexus to your project, you can configure the code in the project Pom.xml file as follows:

 <project> 

<repositories>
<repository>
<id>nexus< /id>
<url>http://http://localhost:4040/nexus/content/groups/public/</url>
<rel Eases><enabled>true</enabled></releases>
<snapshots><enabled>true</ Enabled></snapshots>
</repository>
</repositories>
<pluginrepositories
<pluginrepository>
<id>nexus</id>
<url>http://localhost: 4040/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></ Releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRep Ository>
</pluginrepositories>
</profile>

</project>

This configuration is only valid for the current MAVEN project, and in practice, we often want to do it all in one configuration to make all MAVEN projects in the machine use their own maven. At this point, configure the local warehouse Setting.xml code as follows:

<settings>
  
<mirrors>

<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:4040/content/groups/public/</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>JDK1.6</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.6</jdk>
</activation>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
<id>central</id>
<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>
<activeProfile>central</activeProfile>
<activeProfile>JDK1.6</activeProfile>
</activeProfiles>
</settings>


Deploy artifacts to Nexus using Maven

The snapshot version artifacts generated by the daily development can be deployed directly into the Nexus's snapshot repository, and the artifacts released by the project should be deployed to the Nexus in the host repository where the policy is release. POM. The XML configuration is as follows:

<project>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>nexus releases repository</name>

</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus Snapshots Repository</name>
<url>http://localhost:4040/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>


Nexus Warehouse for Dawn users are read-only in order to be able to deploy artifacts, you also need to configure the authentication information code in Setting.xml as follows:

<servers>

<server>
<id>releases</id>
<username>admin</username>
<password>iapppay</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>iapppay</password>
</server>
</servers>
Nexus PrerequisitesWhether it's a Nexus Open source or a Nexus Professional, they only have a prerequisite that there must be a Java Runtime environment and must be Java 5 or higher. Download NexusNexus has 2 versions, Nexus Open Source and Nexus Professional. Nexus Open Source is a full-featured warehouse management system that can be used for free modification distribution based on the EPL protocol.    Nexus Professional is primarily used for complex large enterprises or organizations.    This article only describes the Nexus Open Source, hereinafter referred to as Nexus. Nexus is Http://www.sonatype.org/nexus/go, there is a full version, there is a war version. The former can be run separately as a jetty-based service, which is a Web application running in servlet Constainer. Install NexusInstalling the Nexus is simple. Unzip the downloaded file to any directory, but be careful that the permissions issue is caused by Windows with a blank folder.    Then configure Nexus_home. The extracted directory has a sonatype-work folder in addition to the Nexus. This folder contains all of the Nexus's warehouses and configuration data, which makes it easier to update to the new Nexus. Of course, the path to this directory can also be modified by nexus_home/conf/nexus.properties. Run Nexus     When you run the nexus, you are actually running a Web server running in 0.0.0.0:8081. The nexus runs inside a jetty servlet container and is then launched through a local encapsulation service tanuki the Java service wrapper. It can be configured to run a Nexus as a UNIX or a service for Windows.    The Nexus or Nexus.bat in the bin directory is the starting point for the service, and the corresponding version is selected through your system. Once launched, you will be able to access the Http://localhost:8081/nexus via the browser Configure Nexus for service
when you use a nexus in a production environment, you should configure the Nexus as a service that lets him run in the background and resume the service after the server restarts. Method is Bin/nexus start

Use Nexus to create a

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.