`

Nexus创建本地Maven仓库

    博客分类:
  • Java
 
阅读更多

0.安装环境

windows 7 x86-64

jdk1.6.0_27 32-bit(假定该环境中已经设置了jdk的环境变量)

maven 3.1.1

nexus-2.9.1-02-bundle

 

1.安装maven3.1.1

1)下载maven

访问maven官方网站http://maven.apache.org/,下载maven包。下载链接为:http://apache.fayea.com/apache-mirror/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip

2)解压下载到的apache-maven-3.1.1-bin.zip到某个目录。(如E:\Eb\Apache Software Foundation\apache-maven-3.1.1)

3)设置环境变量。

第一,添加用户变量M2_HOME(实际应为M3_HOME,懒得改了,下面都用M2_吧),M2_HOME=E:\Eb\Apache Software Foundation\apache-maven-3.1.1


第二,添加用户变量M2,M2=%M2_HOME%\bin


第三,修改用户变量PATH(若没有此变量,则添加一个),PATH=%M2%;%PATH%


4)验证maven是否安装成功。打开命令行,输入mvn -v,显示如下信息即为安装成功。


2.安装nexus

1)下载nexus

访问nexus官方网站http://www.sonatype.org/nexus/,下载nexus-2.9.1-02-bundle.zip。 http://www.sonatype.org/nexus/archived

2)解压至某个目录(如E:\Eb\nexus-2.9.1-02-bundle)

3)开启jetty服务器。找到E:\Eb\nexus-2.9.1-02-bundle\nexus-2.9.1-02\bin\jsw\windows-x86-32(由于jdk安装的是32位版本,因此执行此目录下的文件)目录,执行console-nexus.bat批处理文件,等待命令行执行到如下情况:


不要关闭命令行窗口。

4)访问nexus管理页面。

打开浏览器,输入http://localhost:8081/nexus/,点击页面右上方的Log in超链接,输入默认用户名密码admin/admin123,登录nexus管理页面。

3.配置nexus

1)登录nexus管理页面,点击左侧的Repositories,显示相关的仓库信息,各个仓库的含义可自行百度之。


2)修改默认的存储路径。

安装nexus后,本地仓库默认的jar包存储位置是file:/E:/Eb/nexus-2.9.1-02-bundle/sonatype-work/nexus/storage/central。由于Central仓库占用存储较大,我们可以单独设置其存储位置。

首先,将E:/Eb/nexus-2.9.1-02-bundle/sonatype-work/目录下的所有内容复制到H:/Eb/nexus-2.9.1-02-bundle/sonatype-work/目录下;

第二,选中Central,打开Configuration选项卡,修改Override Local Storage Location项的值为file:/H:/Eb/nexus-2.9.1-02-bundle/sonatype-work/nexus/storage/central,点击页面下方的save按钮。

3)同步索引。

首先,选中Central,点击下方的Configuration选项卡。修改Download Remote Indexes项的值为True。点击页面下方的save按钮。

第二,右键点击Central,弹出菜单中点击Repair Index。

修改完成后的配置如下图:


4)Apache Snapshots和Codehaus Snapshots两个仓库也按照上述1)2)3)步骤修改,只是Override Local Storage Location项分别为file:/H:/Eb/nexus-2.9.1-02-bundle/sonatype-work/nexus/storage/apache-snapshots和file:/H:/Eb/nexus-2.9.1-02-bundle/sonatype-work/nexus/storage/codehaus-snapshots

4.配置maven使用nexus

1)在maven安装目录中找到maven的全局配置文件。E:\Eb\Apache Software Foundation\apache-maven-3.1.1\conf目录下的settings.xml文件。

2)将settings.xml修改为如下配置:

 

[html] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <settings xmlns="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.   <localRepository>E:/.m2/repository</localRepository>  
  8.   
  9.   <pluginGroups>  
  10.       
  11.   </pluginGroups>  
  12.   
  13.   <!-- proxies  
  14.    | This is a list of proxies which can be used on this machine to connect to the network.  
  15.    | Unless otherwise specified (by system property or command-line switch), the first proxy  
  16.    | specification in this list marked as active will be used.  
  17.    |-->  
  18.   <proxies>  
  19.     <!-- proxy  
  20.      | Specification for one proxy, to be used in connecting to the network.  
  21.      |  
  22.     <proxy>  
  23.       <id>optional</id>  
  24.       <active>true</active>  
  25.       <protocol>http</protocol>  
  26.       <username>proxyuser</username>  
  27.       <password>proxypass</password>  
  28.       <host>proxy.host.net</host>  
  29.       <port>80</port>  
  30.       <nonProxyHosts>local.net|some.host.com</nonProxyHosts>  
  31.     </proxy>  
  32.     -->  
  33.   
  34.   </proxies>  
  35.   
  36.     
  37.   <!-- servers  
  38.    | This is a list of authentication profiles, keyed by the server-id used within the system.  
  39.    | Authentication profiles can be used whenever maven must make a connection to a remote server.  
  40.    |-->  
  41.   <servers>  
  42.       
  43.   </servers>  
  44.   
  45.   <!-- mirrors  
  46.    | This is a list of mirrors to be used in downloading artifacts from remote repositories.  
  47.    |   
  48.    | It works like this: a POM may declare a repository to use in resolving certain artifacts.  
  49.    | However, this repository may have problems with heavy traffic at times, so people have mirrored  
  50.    | it to several places.  
  51.    |  
  52.    | That repository definition will have a unique id, so we can create a mirror reference for that  
  53.    | repository, to be used as an alternate download site. The mirror site will be the preferred   
  54.    | server for that repository.  
  55.    |-->  
  56.   <mirrors>  
  57.       
  58.     <mirror>  
  59.       <!--This is used to direct the public snapshots repo in the   
  60.           profile below over to a different nexus group -->  
  61.       <id>nexus-public-snapshots</id>  
  62.       <mirrorOf>public-snapshots</mirrorOf>  
  63.       <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>  
  64.     </mirror>  
  65.     <mirror>  
  66.       <!--This sends everything else to /public -->  
  67.       <id>nexus</id>  
  68.       <mirrorOf>*</mirrorOf>  
  69.       <url>http://localhost:8081/nexus/content/groups/public</url>  
  70.     </mirror>  
  71.   </mirrors>  
  72.     
  73.   <profiles>  
  74.       
  75.     <profile>  
  76.       <id>development</id>  
  77.       <repositories>  
  78.         <repository>  
  79.           <id>central</id>  
  80.           <url>http://central</url>  
  81.           <releases><enabled>true</enabled></releases>  
  82.           <snapshots><enabled>true</enabled></snapshots>  
  83.         </repository>  
  84.       </repositories>  
  85.      <pluginRepositories>  
  86.         <pluginRepository>  
  87.           <id>central</id>  
  88.           <url>http://central</url>  
  89.           <releases><enabled>true</enabled></releases>  
  90.           <snapshots><enabled>true</enabled></snapshots>  
  91.         </pluginRepository>  
  92.       </pluginRepositories>  
  93.     </profile>  
  94.     <profile>  
  95.       <!--this profile will allow snapshots to be searched when activated-->  
  96.       <id>public-snapshots</id>  
  97.       <repositories>  
  98.         <repository>  
  99.           <id>public-snapshots</id>  
  100.           <url>http://public-snapshots</url>  
  101.           <releases><enabled>false</enabled></releases>  
  102.           <snapshots><enabled>true</enabled></snapshots>  
  103.         </repository>  
  104.       </repositories>  
  105.      <pluginRepositories>  
  106.         <pluginRepository>  
  107.           <id>public-snapshots</id>  
  108.           <url>http://public-snapshots</url>  
  109.           <releases><enabled>false</enabled></releases>  
  110.           <snapshots><enabled>true</enabled></snapshots>  
  111.         </pluginRepository>  
  112.       </pluginRepositories>  
  113.     </profile>  
  114.   </profiles>  
  115.   
  116.   <!-- activeProfiles  
  117.    | List of profiles that are active for all builds.  
  118.    |  
  119.   <activeProfiles>  
  120.     <activeProfile>alwaysActiveProfile</activeProfile>  
  121.     <activeProfile>anotherAlwaysActiveProfile</activeProfile>  
  122.   </activeProfiles>  
  123.   -->  
  124.   <activeProfiles>  
  125.     <activeProfile>development</activeProfile>  
  126.   </activeProfiles>  
  127. </settings>  


3)验证是否设置成功。

 

打开命令行,执行如下语句:

 

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
 
  1. mvn help:system  


之后,查看E:/.m2/repository(<localRepository>E:/.m2/repository</localRepository>将maven的默认配置改为该目录,默认配置为C:\Users\<用户名>\.m2\repository)和file:/H:/Eb/nexus-2.9.1-02-bundle/sonatype-work/nexus/storage/central两个目录下都有了新下载到的jar包。则表示配置成功。

分享到:
评论

相关推荐

    nexus maven内部库配置安装手册

    Nexus可以在服务器上建立本地的宿主仓库,你可以往这个仓库里提交任意的Maven规范构件,包括不能从公开仓库下载到的构件,或者你组织内部产生的构件。 仓库组。有了仓库组,你就能将很多仓库聚合起来,对外公开一个...

    用Nexus做Maven私服全攻略

    Nexus可以在服务器上建立本地的宿主仓库,你可以往这个仓库里提交任意的Maven规范构件,包括不能从公开仓库下载到的构件,或者你组织内部产生的构件。 • 仓库组。有了仓库组,你就能将很多仓库聚合起来,对外公开一...

    拥抱AndroidStudio之四:Maven仓库使用与私有仓库搭建

    使用AndroidStudio,必然要与maven仓库频繁打交道,在创造和分享自己打造的Androidlibrary的时候,maven仓库的知识更是必不可少。本章将为开发者系统梳理这方面的知识。笔者曾经不思量力的思考过『是什么推动了...

    maven window下安装包

    第6章:仓库/6.1 何为Maven仓库 第6章:仓库/6.2 仓库的布局 第6章:仓库/6.3 仓库的分类 第6章:仓库/6.3 仓库的分类/6.3.1 本地仓库 第6章:仓库/6.3 仓库的分类/6.3.1 本地仓库/6.3.1.1 setting.xml文件路径 第6...

    IDEA11 Maven3快速入门及应用

    Maven简介 Maven准备 Maven目录分析 Maven本地仓库 IDEA启用Maven功能 IDEA创建Maven工程 IDEA执行Maven命令 Maven配置POM 配置Maven远程仓库(私服)

    Maven环境配置

    Maven环境配置包含了Maven的配置,eclipse配置Maven,使用eclipse创建java、javaWeb项目,配置Maven环境Nexus本地仓库环境。

    Maven实战(高清版)

    背景案例第5章 坐标和依赖第6章 仓库第7章 生命周期和插件第8章 聚合与继承第9章 使用nexus创建私服第10章 使用maven进行测试第11章 使用hudson进行持续集成第12章 使用maven构建web应用第13章 版本管理第...

    nexus 使用教程.docx

    仓库:对maven来说仓库分为两类:本地仓库和远程仓库,远程仓库又分为中央仓库 私服和...有三种专门的Maven仓库管理软件可以用来帮助我们建立私服:chiva、Artifactory和Nexus。Nexus是当前最流行的Maven仓库管理软件。

    maven的优缺点 项目

    只修改本地仓库,和下载镜像(源) 3.2.Eclipse Maven的配置 每打开一个新的工作空间,要配置一下Maven,然后再写代码 3.3.创建Maven项目 右击创建一个maven project Packing:有三种: Jar:java项目, War:web项目 ...

    Maven三种仓库的配置.zip

    要创建本地仓库我们需要有相应的jar包文件,本人经过长时间的寻找和积累,已经有了一个jar包仓库,现将此jar包提供给大家使用。下载地址:http://pan.baidu.com/s/1jH77z2Q。

    nexus-3.28.1-01.tar.gz

    nexus-3.28.1-01.tar.gz 是maven私服工具包,配合jdk8运行。下载后需要解压缩。 maven私服 私服是一种特殊的远程仓库,它是架设在局域网内的仓库服务,私服代理广域网上的远程仓库,供局域网内...建立本地内部公用仓库

    批量上传包dogserver-nexus.multi-upload-master.zip

    该资源主要介绍了通过nexus创建maven私服的过程,以及我们如何将本地仓库的jar包上传到私服上。该服务器适用于我们在内网的开发环境中,不能从外网的远程仓库下载我们所需要的jar包。

    mon_premier_depot_github:在 github 上创建的第一个存储库

    将 WildFly 启动为: ./bin/standalone.sh bin/ ./bin/standalone.sh 将应用程序 WAR 部署到 WildFly: mvn wildfly:deploy 安装到本地 Maven 仓库: mvn install '~/.m2/repository' 中的 repo 将 SNAPSHOT 版本...

Global site tag (gtag.js) - Google Analytics