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


    场景:

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

    问题:

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

    目标:

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


                com.gisquest.cloud
                platform-rulesengine-client
                1.0.7-YWDZ-SNAPSHOT
       
     

    网上搜索了解决方案:

    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类型的都是拉取的仓库的地址

  • 相关阅读:
    巨控GRM530远程模块与西门子上-300PLC远程上下载程序,远程在线调试程序
    【R语言】【4】data.frame与merge与join与cbind与rbind
    linux espidf vscode
    两台windows主机共享文件的方法【简单有效】
    微信小程序
    Windows OpenGL 图像曝光度调节
    uniapp iosApp H5+本地文件操作(写入修改删除等)
    浅谈 Web 3.0
    LeetCode题集——分割链表 + 删除排序链表中的重复元素(1+2)
    一行配置解决JPA + H2 测试时懒加载LazyInitializationException异常
  • 原文地址:https://blog.csdn.net/qq_38423256/article/details/127095546