一个基础类,可能要升级并放到私服库里,为了方便,应该能够自动打包放到nexus。这就需要配置maven一些参数与pom.xml。

依次在settings.xml文件裡輸入

  1. <!-- nexus帳號和密碼-->
  2. <server>
  3. <id>releases</id>
  4. <username>admin</username>
  5. <password>admin123</password>
  6. </server>
  7. <server>
  8. <id>snapshots</id>
  9. <username>admin</username>
  10. <password>admin123</password>
  11. </server>
  12. </servers>
  13. ...
  14. <!-- 引用naxus倉庫組-->
  15. <profile>
  16. <id>dev</id>
  17. <repositories>
  18. <repository>
  19. <id>nexus</id>
  20. <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
  21. <releases>
  22. <enabled>true</enabled>
  23. </releases>
  24. <snapshots>
  25. <enabled>true</enabled>
  26. </snapshots>
  27. </repository>
  28. </repositories>
  29. <pluginRepositories>
  30. <pluginRepository>
  31. <id>nexus</id>
  32. <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
  33. <releases>
  34. <enabled>true</enabled>
  35. </releases>
  36. <snapshots>
  37. <enabled>true</enabled>
  38. </snapshots>
  39. </pluginRepository>
  40. </pluginRepositories>
  41. </profile>
  42. ..
  43. <!-- nexus -->
  44. <activeProfiles>
  45. <activeProfile>dev</activeProfile>
  46. </activeProfiles>

注意:根據標籤位置準確輸入

在本项目的pom.xml配置即可 
<!--上传配置 必须-->

<distributionManagement>
<repository>
<id>releases</id>
<url>http://127.0.0.1:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://127.0.0.1:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<!--上传source.jar 非必须-->

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-source-plugin</artifactId>

<executions>

<execution>

<id>attach-sources</id>

<goals>

<goal>jar</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</build>

上面的ID和pom.xml中对应distributionManagement-> repository的ID,用户名和密码需要在nexus中配置。

完成以上配置,只要输入命令:mvn deploy 即可。

遇到的问题:

maven deploy到nexus报错:Return code is: 401, ReasonPhrase:Unauthorized

提交到nexus时候报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file:http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client* /1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原来是没有配置认证。

maven目录conf的setting.xml里,

  1. <server>
  2. <id>releases</id>
  3. <username>admin</username>
  4. <password>admin123</password>
  5. </server>
  6. <server>
  7. <id>snapshots</id>
  8. <username>admin</username>
  9. <password>admin123</password>
  10. </server>
  11. </servers>

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

    1. <!-- 配置远程发布到私服,mvn deploy -->
    2. <distributionManagement>
    3. <repository>
    4. <id>releases</id>
    5. <name>Nexus Release Repository</name>
    6. <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
    7. </repository>
    8. <snapshotRepository>
    9. <id>snapshots</id>
    10. <name>Nexus Snapshot Repository</name>
    11. <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
    12. </snapshotRepository>
    13. </distributionManagement>

maven自动打包上传nexus仓库配置的更多相关文章

  1. Maven 自动打包上传到私服 Nexus

    转载于:http://blog.csdn.net/jerome_s/article/details/54410178           Maven获取jar的默认顺序是         

  2. Maven配置jar(war)包自动打包上传Maven服务器的配置

    Maven配置jar(war)包自动打包上传Maven服务器的配置 创建jar(war)包工程 创建一个maven工程 在工程中穿件一个测试类 配置pom.xml <distributionMa ...

  3. iOS开发进阶 - 使用shell脚本自动打包上传到fir.im上-b

    用fir.im测试已经好长时间了,感觉每次打包上传都很麻烦,想着是不是可以用脚本自动打包,在网上搜了一下确实有,下面总结一下如何使用脚本自动打包上传到fir.im,以及打包过程中遇到的问题和解决办法 ...

  4. 如何将maven项目打包上传到私服

    比如我们想要把项目通过maven生产源码包和文档包并发布到自己的私服上,有两个maven插件可以做到这些工作,一个是maven-source-plugin,另一个是maven-javadoc-plug ...

  5. 使用shell脚本自动打包上传 fir.im

    http://blog.csdn.net/wang631106979/article/details/52299083

  6. xcodebuild自动打包上传到蒲公英的shell脚本

    注意: ExportOptions.plist (包含了证书相关信息) 该plist 文件可以通过xcode手动导出ipa之后获取到, 区分appstore 和 development的情况 #! / ...

  7. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):4、Maven项目转换与pom.xml配置

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

  8. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):3、Maven独立插件安装与settings.xml配置

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

  9. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1、JIRA账号注册

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

随机推荐

  1. SCRUM 12.21

    从爬虫遇到的问题中我们学会了: 1.有的网站是有反爬虫机制的,外卖网站(我们猜测基本所有盈利性质的网站可能都是)全部都有. 2.我们对于反爬虫机制有了一定的了解.   本次爬虫测试中,我们最后连美团网 ...

  2. Week7阅读笔记

    关于银弹: Brooks在他最著名的这篇文章里指出,在软件开发过程里是没有万能的终杀性武器的,只有各种方法综合运用,才是解决之道.而各种声称如何如何神奇的理论或方法,都不是能杀死“软件危机”这头人狼的 ...

  3. 《Linux内核分析》第八周学习总结

    <Linux内核分析>第八周学习总结                                      ——进程的切换和系统的一般执行过程 姓名:王玮怡  学号:20135116 ...

  4. 实验三 Java敏捷开发与xp实现

    实验内容: 1. XP基础 2. XP核心实践 3. 相关工具 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程 2.完成实 ...

  5. Linux内核分析-系统中断在内核中的实现

    分析system_call中断处理过程 在MenuOS中添加上周所运用到的系统调用 即在Linuxkernel/menu/test.c文件中,添加代码如下: int Mkdir() { const c ...

  6. Sprint 冲刺第三阶段第3-5天

    陈汝婷:数据库的实现 具体实现用户登录在数据库中查找,用户注册的时候可以将用户的具体信息存放于SD卡中.刚学Android的数据库的数据库,还有一些问题.所以这个问题一直拖了几天才解决.问老师问同学, ...

  7. 小学四则运算APP 第一个冲刺阶段 第六天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...

  8. java mail session使用Properties的clone方法

    /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreem ...

  9. HTML 5 Canvas vs. SVG

    pick up from http://www.w3school.com.cn/html5/html_5_canvas_vs_svg.asp Canvas 与 SVG 的比较 下表列出了 canvas ...

  10. [转帖]CR3,PDE,PTE,TLB 内存管理的简单说明

    CR3,PDE,PTE,TLB  Copy From https://www.cnblogs.com/zzSoftware/archive/2013/02/11/2908824.html   网上关于 ...