Build a local network Maven Repository

Source: Internet
Author: User

Step 1: Download nexus

 

Http://nexus.sonatype.org/downloads/download the latest version

Decompress the package to any directory. I directly decompress the package to the E drive ---------- E: \ nexus-2.9.0-04.

The Nexus installation directory contains a sibling directory named "sonatype-work ". This directory contains the configuration information of all the resource libraries and nexus.

 

Step 2: run the server

 

Go to the following directory:

 

E: \ nexus-2.9.0-04 \ bin \ JSW

Select the corresponding system, my Win8 system needs to run as Administrator 1, install-nexus.bat, 2, start-nexus.bat

 

Wait until it is started. After it is started, DOS will be automatically disabled. If it is run again, a message indicating that it is already running is displayed. The default port number is 8081.

 

To use nexus, enter http: // localhost: 8081/nexus in the browser. (You can also use 127.0.0.1 or another configured IP address ). The initial welcome page of nexus is displayed.

Click in the upper-right corner. The log in dialog box is displayed. The default user name is admin and the password is admin123.

Step 3: add an index

 

In the left pane, select repositories. the user-managed resource list is displayed on the right.

1. Apache snapshots

2. codehaus snapshosts

3. Central

Find the above three proxy Remote resource libraries, respectively

In the Configuration window, set "Download remote indexes" to "true" and save the changes.

Nexus can combine multiple repositories, hosted, or proxy into one group. In this way, Maven only needs to rely on one group to use the content of all repositories contained in this group.

Nexus predefines"Public Repositories"Repository group, which combines all pre-defined release repositories by default.

Click"Public Repositories", And then select"Configuration"Tab, in the configuration panel, set"Avaiable Repositories"Move the resource library to the left"Ordered Group Repository"Medium

For internal LAN development, we should configure a single Nexus group to include release and snapshot. To achieve this goal, add the snapshot resource library to our public group and submit the settings file to Maven ~ /. M2/settings. XML (my configuration file configured separately in eclipse, you can use the default) (apache-maven-3.2.2 for Maven installation directory \ conf \ Settings. XML) Add the following image Configuration:

<Settings>
<Mirrors>
<Mirror>
<! -- This sends everything else to/public -->
<ID> nexus </ID>
<Mirrorof> * </mirrorof>
<URL> http: // server IP Address: 8081/nexus/content/groups/Public </URL>
</Mirror>
</Mirrors>
<Profiles>
<Profile>
<ID> nexus </ID>
<! -- Enable snapshots for the built in central repo to direct -->
<! -- All requests to nexus via the mirror -->
<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>
<! -- Make the profile active all the time -->
<Activeprofile> nexus </activeprofile>
</Activeprofiles>
</Settings>

After this configuration, all developers in the team can point to the public repository in the nexus to implement remote proxy (local jar files can be downloaded from the local server, otherwise they can be downloaded from the Internet)

At last, I accompanied my Maven settings. xml

 

<?xml version="1.0" encoding="UTF-8"?><!--Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements.  See the NOTICE filedistributed with this work for additional informationregarding copyright ownership.  The ASF licenses this fileto you under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliancewith the License.  You may obtain a copy of the License at    http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied.  See the License for thespecific language governing permissions and limitationsunder the License.--><!-- | This is the configuration file for Maven. It can be specified at two levels: | |  1. User Level. This settings.xml file provides configuration for a single user,  |                 and is normally provided in ${user.home}/.m2/settings.xml. | |                 NOTE: This location can be overridden with the CLI option: | |                 -s /path/to/user/settings.xml | |  2. Global Level. This settings.xml file provides configuration for all Maven |                 users on a machine (assuming they‘re all using the same Maven |                 installation). It‘s normally provided in  |                 ${maven.home}/conf/settings.xml. | |                 NOTE: This location can be overridden with the CLI option: | |                 -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--><settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  <!-- localRepository   | The path to the local repository maven will use to store artifacts.   |   | Default: ${user.home}/.m2/repository-->  <localRepository>E:/repository</localRepository>    <!-- interactiveMode   | This will determine whether maven prompts you when it needs input. If set to false,   | maven will use a sensible default value, perhaps based on some other setting, for   | the parameter in question.   |   | Default: true  <interactiveMode>true</interactiveMode>  -->  <!-- offline   | Determines whether maven should attempt to connect to the network when executing a build.   | This will have an effect on artifact downloads, artifact deployment, and others.   |   | Default: false  <offline>false</offline>  -->  <!-- pluginGroups   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.   |-->  <pluginGroups>    <!-- pluginGroup     | Specifies a further group identifier to use for plugin lookup.    <pluginGroup>com.your.plugins</pluginGroup>    -->  </pluginGroups>  <!-- proxies   | This is a list of proxies which can be used on this machine to connect to the network.   | Unless otherwise specified (by system property or command-line switch), the first proxy   | specification in this list marked as active will be used.   |-->  <proxies>    <!-- proxy     | Specification for one proxy, to be used in connecting to the network.     |    <proxy>      <id>optional</id>      <active>true</active>      <protocol>http</protocol>      <username>proxyuser</username>      <password>proxypass</password>      

  

 

 

Build a local network Maven Repository

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.