windown搭建maven私仓搭建(nexus3)

本文主要介绍maven私仓在windows下的搭建。
本文主要参考:http://www.cnblogs.com/bingyeh/p/5913486.html
好,下面上货。
1、下载nexus3==>https://www.sonatype.com/download-oss-sonatype

下载windows版本。

2、解压到本地的任意文件夹下。


然后进入nexus-3.3.2-02\bin文件夹下。
在当前文件夹下开启命令行,执行如下命令:
nexus intall

然后进入windows的服务管理页面,能够看到nexus已经成为系统服务了。

使用命令nexus start 启动服务。使用命令 nexus stop 结束服务。

3、进入nexus页面:
http://localhost:8081/


4、使用管理员用户登录:
用户名:admin
密码:admin123

5、进入后新建仓库:


这里需要解释一下我们需要的仓库类型。
我们需要一个代理仓库从网上下载安装包,需要一个release仓库保存已经发布的上线的安装包,还需要一个snapshot用来保存快照的私仓。
最后,这些私仓需要一个统一的访问入口,就是私仓组。

6、分别看一下这几个私仓的配置:
proxy私仓,使用的外部私仓是阿里的仓库http://maven.aliyun.com/nexus/content/groups/public:


release私仓:

snapshot私仓:

group私仓组:

7、如何在项目中使用。

首先需要使用自定义的settings文件,并且在项目中使用新的maven配置。


<?xml version="1.0" encoding="UTF-8"?>
<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>/path/to/local/repo</localRepository>
  -->
 
    <!-- 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>org.sonatype.plugins</pluginGroup>
    </pluginGroups>
 
    <proxies>
    </proxies>
 
    <servers>
        <server>
            <id>nexus</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
 
    <mirrors>
 
        <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.0.120:8081/repository/nexus-public/</url>
        </mirror>
    </mirrors>
 
    <profiles>
        <profile>
            <id>nexus</id>
            <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>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>


然后,还需要在pom文件中指定要上传的私仓名称,在pom文件最后添加如下内容。


<distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Releases</name>
            <url>http://192.168.0.120:8081/repository/nexus-releases</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>Snapshot</name>
            <url>http://192.168.0.120:8081/repository/nexus-snapshots</url>
        </snapshotRepository>
    </distributionManagement>

这样,在使用mavendeploy上传jar包的时候,就能够根据当前的版本上传到release或者snapshot上了。
8、查看私仓是否上传成功。
转载:https://blog.csdn.net/wild46cat/article/details/73697109 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值