使用Nexus搭建本地仓库


一.下载和安装Nexus

1.下载Nexus

下载地址:https://www.sonatype.com/download-oss-sonatype,
进入页面,选择相应的版本(以windows为例),点击下载。

2.安装和启动Nexus

1) 配置JDK/JRE

(注意:需要JDK 8的运行环境)

Nexus自带了一个JRE,但可能无法直接使用,需要使用运行以下命令:

使用jre/bin 下的 unpack200 工具解包rt.jar.pack

unpack200 rt.jar.pack rt.jar

如有需要,可解包其它 .jar.pack 文件

2)启动Nexus

命令行启动

  • 在打开命令窗口,进入bin目录,使用命令
    nexus.exe /run

安装为Windows服务

  • 在打开命令窗口,进入bin目录,使用命令

    nexus.exe /install

    安装名为nexus的服务

    打开浏览器输入:http://localhost:8081 ,这时会打开Nexus的初始欢迎界面,如下图所示

    点击右上角Sign in ,进入管理员模式。(用户名:admin 密码:admin123)

二.配置Maven

1.配置 setting.xml

  • 找到Maven 的setting.xml文件(例如:E:\maven\apache-maven-3.5.0\conf)

  • 打开setting.xml文件,把如下代码放到相应位置。

    <settings>
    <mirrors>
     <mirror>
       <!--This sends everything else to /public -->
       <id>nexus</id>
       <mirrorOf>*</mirrorOf>
       <url>http://localhost:8081/repository/maven-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>

    参考https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ProxyingMavenRepositories


文章作者: Rabbit
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Rabbit !
 上一篇
CentOS IP 配置 CentOS IP 配置
第一、编辑ifcfg-eth0文件vi /etc/sysconfig/network-scripts/ifcfg-eth0 将BOOTPROTO后面参数确认是static 第二、创建新IP配置文件配置文件vi /etc/sysconfig/
2018-03-14 Rabbit
本篇 
使用Nexus搭建本地仓库 使用Nexus搭建本地仓库
一.下载和安装Nexus1.下载Nexus 下载地址:https://www.sonatype.com/download-oss-sonatype,进入页面,选择相应的版本(以windows为例),点击下载。 2.安装和启动Nexus1)
2017-12-25 Rabbit
  目录