• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

maven推送本地jar包到nexus仓库遇到的问题

武飞扬头像
喜羊羊love红太狼
帮助1

场景:

今天使用jenkins打包镜像时,发现其中一个jar包私服仓库没有,本地是有的,因此遇到如何从本地向nexus仓库推送的问题(之前没有推过现在遇到一些坑特此记录一下)

问题:

如何正确地从本地向nexus仓库推送jar包

目标:

将本地的   latform-rulesengine-client 的jar包推送到nexus上    

<dependency>
            <groupId>com.gisquest.cloud</groupId>
            <artifactId>platform-rulesengine-client</artifactId>
            <version>1.0.7-YWDZ-SNAPSHOT</version>
   </dependency> 

网上搜索了解决方案:

  1.  
    mvn deploy:deploy-file 
  2.  
    -DgroupId=com.gisquest.cloud 
  3.  
    -DartifactId=platform-rulesengine-client 
  4.  
    -Dversion=1.0.7-YWDZ-SNAPSHOT 
  5.  
    -Dpackaging=jar 
  6.  
    -Dfile=C:\Users\Administrator\Desktop\tui\platform-rulesengine-client-1.0.7-YWDZ-SNAPSHOT.jar 
  7.  
    -Durl=http://192.168.11.70:8081/nexus/content/groups/public/ 
  8.  
    -DrepositoryId=nexus

注解:

-DgroupId 、-DartifactId、-Dversion分别和该包的坐标依赖相对应

-Dpackaging:表示准备推到nexus上包的类型

-Dfile :表示要从本地推到nexus上包的绝对路径(重要)

-Durl: 表示私服仓库的地址(重要)

-DrepositoryId:表示私服仓库对应的唯一id

我本地pom.xml的配置如下(maven中setting.xml文件中私服的url都是一样的):

  1.  
    <!-- 设定主仓库,按设定顺序进行查找。 -->
  2.  
    <repositories>
  3.  
    <repository>
  4.  
    <id>nexus</id>
  5.  
    <name>nexus</name>
  6.  
    <url>http://192.168.11.70:8081/nexus/content/groups/public/</url>
  7.  
    <releases>
  8.  
    <enabled>true</enabled>
  9.  
    </releases>
  10.  
    <snapshots>
  11.  
    <enabled>true</enabled>
  12.  
    </snapshots>
  13.  
    </repository>
  14.  
    </repositories>

按理说执行上面推动命令应该就可以了,但是执行后发现报错了提示如下错误400 Bad Request 路径找不到:

  1.  
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
  2.  
    Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.gisquest.cloud:platform-rulesengine-client:jar:1.0.7-YWDZ-20220928.030757-1 from/to nexus (http://192.168.11.70:8081/nexus/content/groups/public): Transfer failed for http://192.168.11.70:8081/nexus/content/groups/public/com/gisquest/cloud/platform-rulesengine-client/1.0.7-YWDZ-SNAPSHOT/platform-rulesengine-client-1.0.7-YWDZ-20220928.030757-1.jar 400 Bad Request

最终在同事的帮助下查看了私服仓库中的配置,发现了该http://192.168.11.70:8081/nexus/content/groups/public路径私服仓库的类型是group

学新通

nexus中仓库类型proxy、hosted、group 简介

代理仓库(proxy):用来代理远程公共仓库,如Maven中央仓库(即拉取仓库)。

仓库组(group):用来聚合代理仓库和宿主仓库,提供统一的服务地址,以便Maven获得仓库中的构件(即拉取仓库)

宿主仓库(hosted):部署本地项目所产生的构件(即推送仓库)

因此正确的推送命令应该是:私服仓库hosted类型上面命令修改如下即可:

 -Durl=http://192.168.11.70:8081/nexus/content/repositories/snapshots/  

结论:

推送时:-Durl路径应该是hosted类型的私服仓库地址,项目中一般配置proxy、group类型的都是拉取的仓库的地址

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhibajbi
系列文章
更多 icon
同类精品
更多 icon
继续加载