Maven-3.7.1版本私服配置

本文详细介绍了如何使用Nexus 3搭建私有仓库,并通过Maven进行Jar包的上传及配置过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

服务端配置:

1.     首先下载nexus,下载地址如下:https://www.sonatype.com,选择自己需要的版本。此文档是nexus-3.7.1-02

2.     解压到本地的目录,会有两个文件夹nexus-3.7.1-02/sonatype-work

3.     使用cmd命令进入nexus-3.7.1-02\bin目录下,执行命令nexus.exe /run。当出现Started Sonatype Nexus OSS 3.7.1-02字样时服务就启动成功了。

4.     在浏览器中输入http://localhost:8081就可以进入一下页面

5.     然后点击右上角的sign in如下图

登陆用户名是admin。密码是admin123

6.     登陆成功后点击设置按钮,如下图

7.            然后按照下图步骤增加Repository

在此界面点击 create repositories出现以下界面


然后就创建成功自己的repositories,回到以下页面可以看到自己创建的


8.     服务端的配置基本完成,接下来就是利用maven上传jar.首先需要在本地安装上maven,安装maven的过程此文档不做介绍。

9.     打开maven下的setting.xml在<servers></servers>下添加一下代码

<server>  

              <id>nexus-3rdParty</id>   #此id是自己定义的,可随意

              <username>admin</username>   #这是nexus的登陆名

              <password>admin123</password>   #这是nexus的登陆密码

       </server>

10.   然后利用mvn命令执行上传jar:

a)     示例:mvn deploy:deploy-file-DgroupId=com.test -DartifactId=example -Dversion=1.0.0 -Dpackaging=jar-Dfile=D:\新建文件夹\component_encrypto-2.0.0.jar-Durl=http://127.0.0.1:8081/repository/3rdParty/-DrepositoryId=nexus-3rdParty   

b)     参数解释:

DgroupId:jar包的groupId

-DartifactId:jar包的artifactId

-Dversion:jar包版本

-Dfile:本地jar文件路径

-Durl:远程仓库url,如ip:8081/

-DrepositoryId:仓库id,对应<server>下<id>节点值,如上面<server>配置为nexus-3rdParty,则必须为该值,否则提示401,认证失败

11.   上传成功后可在浏览器中查看

12.   接下来是maven使用私服地址的配置,打开setting.xml文件在<mirrors></mirrors>之间添加一下代码:

<mirror>

      <id>nexus-3rdParty</id>  #此id和上面的server的id相同

      <mirrorOf>*</mirrorOf>  

     <url>http://192.168.121.130:8081/repository/3rdParty/</url>  #url和上传jar包的url相同

</mirror>

13.   在<profiles></profiles>之间增加一下代码:

<profile> 

      <id>nexus</id> #自定义id

      <repositories> 

        <repository> 

         <id>nexus-3rdParty</id> #和server的id相同

         <url>http://nexus-3rdParty</url> 

         <releases><enabled>true</enabled></releases> 

          <snapshots><enabled>true</enabled></snapshots> 

        </repository> 

       </repositories> 

       <pluginRepositories> 

         <pluginRepository> 

              <id>nexus-3rdParty</id> #和server的id相同

              <url>http://nexus-3rdParty</url> 

              <releases><enabled>true</enabled></releases> 

              <snapshots><enabled>true</enabled></snapshots> 

          </pluginRepository> 

       </pluginRepositories> 

 

   </profile>

14.   在最后的</settings>之上增加一下代码:

<activeProfiles>

    <activeProfile>nexus</activeProfile>#和上面的profile的id相同

 </activeProfiles>

 

       完成以上步骤就算完成了maven的私服配置了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值