Maven Learning (Medium)-Nexus Building

Source: Internet
Author: User
Tags jboss sonatype

Continue, I believe everyone on maven every time the Internet from the foreign site download dependencies of the Turtle Speed network has not been tolerated, today first to see how to build a "warehouse", currently Nexus is one of the more extensive use of the software, the following will introduce basic usage:

First, to the Nexus website to download the latest version

1.1 : Http://www.sonatype.org/downloads/nexus-latest-bundle.zip (currently the latest version is 2.7.2-03)

(2015-07-02 Note: The above image has expired, the new address is http://www.sonatype.org/nexus/archived/)

1.2 After downloading, extract to the specified directory, for example: c:\java\nexus\

1.3 Start Nexus

%nexus_home%\bin\nexus.bat Install (installed as a Windows service)

%nexus_home%\bin\nexus.bat Start (start)

Tips: Direct nexus.bat with no parameters, full list of parameters is displayed

Reference, if not enabled, check the JDK version,Nexus requires 1.7 version (if the version is not correct, adjust the environment variable java_home to the jdk1.7 directory)

If 1.7 is not enabled, it is recommended to enable it with the Nexus.bat console console so you can see the detailed boot process

After successful launch, you can use Http://localhost:8081/nexus to enter the control interface.

In the upper right corner, click Log in, the default username/password is admin/admin123

Second, add JBoss repository address

2.1 Understand the Nexus's repository type first:

Hosted Repository -Nexus native repository (equivalent to a jar, Pom file library already exists on the server hard disk of the Nexus)

Proxy Repository -Agent library, a lot of open source organizations have published the Repository on the internet for developers around the world, after the Nexus set up this type of library, other developers using the Nexus, Ostensibly on the request of a Nexus Server Jar package, but Nexus is essentially behind the request for these Internet resources, the first time the server does not have resources, from the Internet download to the Nexus Server (file form to the hard disk), and then back to the developer, The next time you have the same Pom/jar request, return directly from the server's hard drive and no longer request Internet

Repository Group-resource groups, such as we have a lot of libraries: library A, repository B ..., you can combine them into a special resource C, and then other developers, in Maven, configure the resource C address, So maven in the request jar package to resource C, in essence will search for resource A, resource B

2.2 Adding the JBoss Proxy resource pool

Maven defaults to the official repository http://repo1.maven.org/maven2/, many third-party jar packages are not, so I'll add another JBoss repository

Click on the left side of the repositories, and then click on the right of add, the drop-down menu will pop up, choose proxy Repository

Next, refer to fill in:

Respository ID fill in here: Jboss-public-repository-group (can change name)

Respository name fill out here: JBoss public Maven Repository Group (can change name)

Other items remain default

The Remote Storage location is filled in here: https://repository.jboss.org/nexus/content/groups/public-jboss/(This is the publicly available repository for JBoss release)

2.3 Download the offline Resource pack for JBoss EAP 6.x

When using the Nexus for the first time, there is essentially no cache of any jar packages on the server, so the first time you use it, it's not the same as just downloading directly to the Internet, and only then requesting the same jar package, the server will have the jar file cache, in order to speed up, We can download the offline Resource pack directly on the JBoss website.

: Htp://www.jboss.org/jbossas/downloads

Then extract to the specified directory, it is recommended to put under%nexus_home%\sonatype-work\nexus\storage\

Then add a hosted Repository, refer to:

2.4 Add the two respoitory you just added to the public repositories group

We have just added two new repositories to check if they are included in the default public repositories group.

If not included in the group, refer to the processing and then save. Finally, it is recommended to update the index, refer to:

Third, modify the current user under the. M2 Directory of Settings.xml

1 <?XML version= "1.0" encoding= "UTF-8"?>2 3 <Settingsxmlns= "http://maven.apache.org/SETTINGS/1.0.0" 4 Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemalocation= "http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">6 7   <Mirrors>8     <Mirror>9       <ID>Nexus</ID>Ten       <mirrorof>*</mirrorof>      One       <URL>http://192.168.0.110:8081/nexus/content/groups/public/</URL> A     </Mirror>      -   </Mirrors>   -    the   <Profiles> -     < Profile> -       <ID>Nexus</ID> -       <repositories> +         <Repository> -           <ID>Nexus</ID> +           <name>Nexus</name> A           <URL>http://192.168.0.110:8081/nexus/content/groups/public/</URL> at           <releases><enabled>True</enabled></releases> -           <Snapshots><enabled>True</enabled></Snapshots> -         </Repository> -       </repositories> -       <pluginrepositories> -         <pluginrepository> in           <ID>Nexus</ID> -             <name>Nexus</name> to             <URL>http://192.168.0.110:8081/nexus/content/groups/public/</URL> +             <releases><enabled>True</enabled></releases> -             <Snapshots><enabled>True</enabled></Snapshots> the         </pluginrepository> *       </pluginrepositories> $     </ Profile>Panax Notoginseng   </Profiles> -   <Activeprofiles> the     <Activeprofile>Nexus</Activeprofile> +   </Activeprofiles> A  the  </Settings>

Note: The address in this XML is replaced by the IP of the Nexus server.

Then create a MAVEN project, execute the MVN clean package, and watch the output:

As you can see, dependencies are now downloaded from the Nexus server

Iv. adding resource XML in Eclipse

Finally, I would like to add a little trick, which is really not very related. Every time we create MAVEN project in Eclipse, we pop up an interface that lets us select "project template," a process that requires networking to get a list of templates, and every time it's repeated, it's unreasonable, such as:

You can click on Confiure, the following screen will pop up, click "Add Local Catalog"

First access the Https://repository.jboss.org/nexus/content/groups/public-jboss/archetype-catalog.xml address in the browser, and then save it as an XML file, Next to the interface in the Catalog file, select the XML file, and then description fill in a name

Then, when you create a MAVEN project, you can select this directly, and when you choose, the contents of the native XML will be read directly, much faster than the Internet access.

Finally give a little trick:

Sometimes, in the unit's LAN Architecture Nexus Server, the server does not have access to the external network, so that can not be downloaded from the Internet through the Agent Library jar package, it is possible to do:

Developers of the machine is usually able to access the Internet, first in the machine modified settings.xml, do not go to the nexus, directly from the Internet central Warehouse download once, all things compiled, the local "Current user \.m2\repository" Copy the corresponding storage directory to the Nexus server, typically the Sonatype-work\nexus\storage\central directory in the Nexus Sibling directory, and then log in to the Nexus Admin interface to manually update the index. Other people will be able to use the nexus as usual.

The next section will learn how to use profile to generate deployment packages for various environments

Maven Learning (Medium)-Nexus Building

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.