阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Nexus配置和使用详解

163次阅读
没有评论

共计 2874 个字符,预计需要花费 8 分钟才能阅读完成。

Nexus 安装

nexus 安装,可以参照:Linux 环境 Nexus(Maven 仓库私服)下载与安装 http://www.linuxidc.com/Linux/2017-03/141230.htm

Nexus 简单说明

  • 用途:指定私服的中央地址、将自己的 Maven 项目指定到私服地址、从私服下载中央库的项目索引、从私服仓库下载依赖组件、将第三方项目 jar 上传到私服供其他项目组使用
  •   仓库:

hosted  类型的仓库,内部项目的发布仓库

releases 内部的模块中 release 模块的发布仓库

snapshots 发布内部的 SNAPSHOT 模块的仓库

3rd party 第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去

proxy  类型的仓库,从远程中央仓库中寻找数据的仓库

group  类型的仓库,组仓库用来方便我们开发人员进行设置的仓库

Nexus 配置和使用详解

Nexus 配置

nexus 配置大部分使用默认配置即可,主要是配置一个项目索引

选择 Central 仓库,设置 Download Remote Indexes:True

Nexus 配置和使用详解

Nexus 使用

  • 项目使用 nexus 私服的 jar 包,在项目的 pom.xml 文件中指定私服仓库
     1 <repositories>
     2     <repository>
     3         <id>nexus</id>
     4         <name>nexus</name>
     5         <url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
     6         <releases>
     7             <enabled>true</enabled>
     8         </releases>
     9         <snapshots>
    10             <enabled>true</enabled>
    11         </snapshots>
    12     </repository>
    13 </repositories> 
  • 项目使用 nexus 私服的插件,在项目的 pom.xml 文件中指定插件仓库
     1 <pluginRepositories>
     2     <pluginRepository>
     3         <id>nexus</id>
     4         <name>nexus</name>
     5         <url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
     6         <releases>
     7             <enabled>true</enabled>
     8         </releases>
     9         <snapshots>
    10             <enabled>true</enabled>
    11         </snapshots>
    12     </pluginRepository>
    13 </pluginRepositories> 
  • 如果想本机所有的 maven 项目都使用私服的组件,可以在 maven 的设置文件 settings.xml 中添加属性,并激活
     1 <profiles>
     2     <profile>
     3         <id>nexusProfile</id>
     4         <repositories>
     5             <repository>
     6                 <id>nexus</id>
     7                 <name>nexus</name>
     8                 <url>http://192.168.1.103:8081/nexus/content/groups/public/</url>
     9                 <releases>
    10                     <enabled>true</enabled>
    11                 </releases>
    12                 <snapshots>
    13                     <enabled>true</enabled>
    14                 </snapshots>
    15             </repository>
    16         </repositories>
    17     </profile>
    18 </profiles>
    19 <!-- 激活 -->
    20 <activeProfiles>
    21     <activeProfile>nexusProfile</activeProfile>
    22 </activeProfiles> 
  •  项目发布到私服,maven 项目使用命令:mvn clean deploy;需要在 pom 文件中配置一下代码;
     1 <distributionManagement>
     2         <repository>
     3             <id>user-release</id>
     4             <name>User Project Release</name>
     5             <url>http://192.168.1.103:8081/nexus/content/repositories/releases/</url>
     6         </repository>
     7 
     8         <snapshotRepository>
     9             <id>user-snapshots</id>
    10             <name>User Project SNAPSHOTS</name>
    11             <url>http://192.168.1.103:8081/nexus/content/repositories/snapshots/</url>
    12         </snapshotRepository>
    13     </distributionManagement>

    注意还需要配置 mvn 发布的权限,否则会报 401 错误,在 settings.xml 中配置权限,其中 id 要与 pom 文件中的 id 一致

     1 <server>
     2     <id>user-release</id>
     3     <username>admin</username>
     4     <password>admin123</password>
     5 </server>
     6 <server>
     7     <id>user-snapshots</id>
     8     <username>admin</username>
     9     <password>admin123</password>
    10 </server>

    发布成功后,可以在 nexus 中看到

Nexus 配置和使用详解

  •   上传第三方的 jar 包,选择 3rd party–>Artifact Upload–> 选择 GAV 方式 –> 填好构建参数 –> 增加 jar 包 –> 上传,在 Browse Storeage 查看

  Nexus 配置和使用详解

  Nexus 配置和使用详解

Maven 使用入门 http://www.linuxidc.com/Linux/2012-11/74354.htm

Nexus 安装与配置  http://www.linuxidc.com/Linux/2016-09/135084.htm

Ubuntu 下 搭建 Nexus Maven 私服中央仓库  http://www.linuxidc.com/Linux/2016-08/133936.htm

Linux 下使用 Nexus 搭建 Maven 私服详解 http://www.linuxidc.com/Linux/2016-08/134630.htm

Linux 下使用 Nexus 搭建 Maven 私服 http://www.linuxidc.com/Linux/2016-08/134617.htm

Linux 下安装配置 Nexus http://www.linuxidc.com/Linux/2016-09/135083.htm

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-03/141231.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计2874字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中