Maven(四)maven私服的搭建

1. Maven私服的搭建

1.1 私服搭建

公司一般都有个自己的私服来管理各种jar包,原因大概有这么3个,分别是:

1、有的公司不能访问外网,只能通过私服来管理jar包和插件;
2、公司网速比较慢,通过公司的私服来获取jar包比较快;
3、内部的的一些jar包放在私服上,比较方便的大家使用。

第一步去下载Nexus安装文件:http://www.sonatype.org/nexus/go ,nexus-2.13.0-01-bundle.tar.zip;并解压缩:

第二步访问 http://localhost:8081/nexus 默认账号 admin 密码 admin123

私服搭建成功之后我们可以上传我们的本地jar包到私服仓库中 从maven的中心库找不到这个jar包的坐标,同时已经拥有了这个jar。

1.2 私服集成到项目

第一种声明到局部:

<repositories>
   <repository>
      <id>nexus</id>
      <name>nexus</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
   </repository>
</repositories>

 

 

 

 

 

 

 

 

第二种声明到全局:在全局Setting中配置

<profile>
     <id>nexus</id>
     <repositories>
          <repository>
               <id>nexus</id>
               <name>nexus</name>
               <url>http://localhost:8081/nexus/content/groups/public/</url>
               <releases>
                    <enabled>true</enabled>
               </releases>
               <snapshots>
                    <enabled>true</enabled>
               </snapshots>
          </repository>

     </repositories>

</profile>

 

 

 

 

 

 

 

 

 

 

1.3 打包本地项目到私服

第一步在项目的Pom文件中声明私服仓库地址:

第二步在全局中声明账号和密码(id必须保持一致):

第三步执行maven deploy命令:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值