Maven私服配置简单版

  百度文章一搜一大堆,这里就不详细说了,点一下吧,windows安装可以参考https://www.cnblogs.com/huangheng01/p/10304947.html

    1)下载地址:https://www.sonatype.com/download-oss-sonatype

    2)进入bin目录,安装nexus服务(管理员cmd窗口): nexus /install Nexus3

    3)启动服务,等一会,访问http://localhost:8081

        登录默认密码:admin/admin123,好像是14版本后,密码是随机的,登录时,会有提示:密码在哪个文件中,直接复制,登录,提示修改密码,记住。最好将中央库改成阿里云的,要不然太慢了。

    1.配置下载jar(配置后,本地仓库没有的jar,会从私服中代理仓库下载到私服,再下载到本地),我把能配置的都配置了,经过验证,没有问题。

<!--服务器信息,id可自取,不过需要和下面的id对应-->
<server>
    <id>localNexus</id>
    <username>admin</username>
    <password>admin123</password>
</server>
<!--私服镜像-->
<mirror>
    <id>localNexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://localhost:8081/repository/maven-public/</url>
</mirror>
<!--jar和插件下载配置-->
<profile>
     <id>localNexus</id>
         <repositories>
              <repository>
                  <id>localNexus</id>
                  <name>Nexus </name>
                  <!-- 这里地址直接配置成  http://central-->
                   <url>http://localhost:8081/repository/maven-public/</url>
                  <releases><enabled>true</enabled></releases>
                  <snapshots><enabled>true</enabled></snapshots>
              </repository>
          </repositories>
          <pluginRepositories>
              <pluginRepository>
                  <id>localNexus</id>
                  <name>Nexus Plugin Repository</name>
                  <url>http://localhost:8081/repository/maven-public/</url>
                  <releases><enabled>true</enabled></releases>
                  <snapshots><enabled>true</enabled></snapshots>
              </pluginRepository>
          </pluginRepositories>
</profile>
<!--激活上面profile配置-->
<activeProfiles>
    <activeProfile>localNexus</activeProfile>
</activeProfiles>

    2.上传项目

        在需要上传的项目pom中配置需要上传到私服的地址,如下

<distributionManagement>
    <snapshotRepository>
        <id>localNexus-snapshots</id>
        <name>localNexus-snapshots</name>
        <url>http://localhost:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

        settings.xml文件配置服务器用户,密码(注意和上面的id保持一致),如下:

<server>
    <id>localNexus-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
</server>

        执行命令 mvn  clean  deploy,完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值