Setting up a maven (using Nexus)

Source: Internet
Author: User
Tags maven central

What can I do with the building?
1, if the development of the company's development environment all intranet, then how to connect to the MAVEN central warehouse on the Internet?
2, if the company often develop some common components, how to share to each development group, using the Copy method? If so, what if the public library is upgraded?

Of course the problem can be solved more than two points above, the following to build their own Maven in Linux, using the Nexus.

First, download and install

Website: http://www.sonatype.org/nexus/go/

Download package: nexus-2.12.0-01-bundle.tar.gz
Unpacking Package: TAR-ZXVF nexus-2.12.0-01-bundle.tar.gz
The default port is 8081, if you want to modify please check the configuration file conf/nexus.properties
It is not recommended to use under the root user, if we need to start the service under the root user, first configure the run_as_user=root in the Bin/nexus file

Ii. start-Up and configuration

Start

[Email protected] nexus-maven]# CD Nexus-2.12.0-01/bin/[[email protected] bin]#./nexus start****************************************Warning-not RECOMMENDED to RUN as ROOT****************************************Starting Nexus OSS ... Started Nexus OSS. [Email protected] bin]#./nexus status****************************************Warning-not RECOMMENDED to RUN as ROOT****************************************Nexus OSS is running (34504). [Email protected] bin]#

After start visit home: http://192.168.19.130:8081/nexus/index.html

login default account/password admin/admin123

Open repositories Download Remote Indexes in the Configuration of all items in the list of type proxy to True

set deployment policy for the releases warehouse to *allow redeploy

set Deployment account password

Then right-click on the central Warehouse and Repair index file in the center warehouse, after some time, click Browse Index below to see the downloaded index file.

Of course, we can avoid the use of some third-party jars, which do not exist in the MAVEN central repository on the Internet, when we add jars to our database by hand.
Add a third-party jar as follows:

If you need to delete, as follows:

Iii. Local project configuration reference

To configure the private address in the pom.xml of the project, add the following pom.xml:

    <!--Private Warehouse --    <repositories>          <repository>              <ID>Public</ID>  <!--This ID needs to be consistent with your group ID--             <name>Public Repository</name>            <URL>Http://192.168.19.130:8081/nexus/content/groups/public</URL>           </repository>      </repositories>     <!--Package release --    <distributionmanagement>        <repository>            <ID>Releases</ID><!--This ID needs to match the repository ID of your release warehouse--            <URL>Http://192.168.19.130:8081/nexus/content/repositories/releases</URL>        </repository>        <snapshotrepository>            <ID>Snapshots</ID><!--This ID needs to match the repository ID of your snapshots warehouse--            <URL>Http://192.168.19.130:8081/nexus/content/repositories/snapshots</URL>        </snapshotrepository>    </distributionmanagement>

To configure server account information in Settings.xml:

  <servers>     <server>        <ID>Releases</ID>        <username>Deployment</username>        <password>Dev123</password><!--This password is the password you set--    </Server>    <server>        <ID>Snapshots</ID>        <username>Deployment</username>        <password>Dev123</password><!--This password is the password you set--    </Server>  </Servers>

One thing to note:
When releases warehouses and snapshots warehouses are also configured in Pom.xml.
The version configuration 1.0.0-snapshot the beginning of the Pom.xml file is the build to the snapshots library,
Version configuration 1.0.0 (without-snapshot) at the beginning of the Pom.xml file will build to the releases library,
If only the releases library is configured and the version number is written with-snapshot, the build to the last step will report a 400 error because it cannot find the corresponding library.

Iv. Testing

1, create a simple Maven project, write a class.
In the Pom.xml file, add a private warehouse and a packaged release configuration by referring to the above three, local project configuration
After using the command MVN deploy successfully, we can see the post-release results in our list as follows:

2. Create a new project, or use an existing MAVEN project (preferably using someone else's environment on a different computer).
After you configure the private library address in Pom.xml and 1th, and then add the dependency after the 1th step, you can see that the jar is loaded into the project properly.

Setting up a maven (using Nexus)

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.