Maven 私服搭建和使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yiyijianxian/article/details/80148201

一、下载安装

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

2.下载完成后解压任意目录,我的是D:\soft\nexus2\nexus-2.14.8-01

3.安装

 在D:\soft\nexus2\nexus-2.14.8-01\bin\jsw\windows-x86-64下找到install-nexus 运行安装成为windows服务

,安装运行完之后运行start-nexus 启动文件

4.访问你的本地私服地址:http://localhost:8081/nexus/

用户名密码 默认是:admin admin123

5.点击login进行登录


二、配置仓库

6.点击左边Repositories,可以看到一系列仓库类型,我们一般使用3个,分别是Releases,Snapshots和3rdparty。这3个仓库风别是装稳定版,开发版和第三方jar包 。

7、开启远程索引

分别选择type为proxy的三个库Apache Snapshots、Central、Codehaus Snapshots

将Download Remote Indexes设置为true

在Apache Snapshots,Codehaus Snapshots和Central这三个仓库上分别右键,选择Repari Index


只有Central库下载索引文件成功,另两个中央库是Not published状态

8、health check

点击绿色的analyze


点击YES。

三、maven配置文件的配置

9.mvn直接发布到私服上面来

 在settings文件的servers节点下加入,这是配置私服的密码和仓库,配合pom文件中的仓库地址就构成了完成的访问私服的要素,帐号和密码之所以在settings中设置,是由于settings文件是本地的,而pom.xml文件是公共的,不安全,所以放在settings中:


<server>

      <id>nexus-releases</id>

      <username>admin</username>

      <password>admin123</password>

    </server>

     <server>

        <id>nexus-snapshots</id>

        <username>admin</username>

       <password>admin123</password>

</server>

四、工程配置

10.其他工程引用私服地址

项目工程引用配置:http://127.0.0.1:8081/nexus/content/repositories/central/


<repositories>

  <repository>

    <id>my-maven</id>

    <name>My Maven</name>

    <url>http://127.0.0.1:8081/nexus/content/repositories/central/</url>

    <releases>

      <enabled>true</enabled>

    </releases>

    <snapshots>

      <enabled>true</enabled>

    </snapshots>

  </repository>

</repositories>

查看一下私服提供的jar


11.对外提供服务的组配置






猜你喜欢

转载自blog.csdn.net/yiyijianxian/article/details/80148201