Maven 自动打包上传到私服 Nexus
转载于:http://blog.csdn.net/jerome_s/article/details/54410178

上传私服 pom.xml 配置
|
1
2
3
4
5
6
7
8
9
10
|
<distributionManagement > <repository > <id >releases </id > </repository > <snapshotRepository > <id >Snapshots </id > </snapshotRepository ></distributionManagement > |
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<servers> <server> <id>releases</id> <username>admin</username> <password>qsapwd</password> </server> <server> <id>Snapshots</id> <username>admin</username> <password>qsapwd</password> </server> </servers> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<build> <plugins> <plugin> <!-- 打jar包 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <excludes> <exclude>**/*.properties</exclude> </excludes> </configuration> </plugin> <plugin> <!-- 打源码 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.4</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> |

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
一个基础类,可能要升级并放到私服库里,为了方便,应该能够自动打包放到nexus。这就需要配置maven一些参数与pom.xml。
依次在settings.xml文件裡輸入
- <!-- nexus帳號和密碼-->
- <server>
- <id>releases</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- <server>
- <id>snapshots</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- </servers>
- ...
- <!-- 引用naxus倉庫組-->
- <profile>
- <id>dev</id>
- <repositories>
- <repository>
- <id>nexus</id>
- <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>nexus</id>
- <url>http://127.0.0.1:8081/nexus/content/groups/public</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- ..
- <!-- nexus -->
- <activeProfiles>
- <activeProfile>dev</activeProfile>
- </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里,
- <server>
- <id>releases</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- <server>
- <id>snapshots</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- </servers>
用户名和密码都是nexus的。再次deploy即可。
注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:
- <!-- 配置远程发布到私服,mvn deploy -->
- <distributionManagement>
- <repository>
- <id>releases</id>
- <name>Nexus Release Repository</name>
- <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
- </repository>
- <snapshotRepository>
- <id>snapshots</id>
- <name>Nexus Snapshot Repository</name>
- <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
- </snapshotRepository>
- </distributionManagement>
Maven 自动打包上传到私服 Nexus的更多相关文章
- maven自动打包上传nexus仓库配置
一个基础类,可能要升级并放到私服库里,为了方便,应该能够自动打包放到nexus.这就需要配置maven一些参数与pom.xml. 依次在settings.xml文件裡輸入 <!-- nexus帳 ...
- 如何将maven项目打包上传到私服
比如我们想要把项目通过maven生产源码包和文档包并发布到自己的私服上,有两个maven插件可以做到这些工作,一个是maven-source-plugin,另一个是maven-javadoc-plug ...
- Maven配置jar(war)包自动打包上传Maven服务器的配置
Maven配置jar(war)包自动打包上传Maven服务器的配置 创建jar(war)包工程 创建一个maven工程 在工程中穿件一个测试类 配置pom.xml <distributionMa ...
- iOS开发进阶 - 使用shell脚本自动打包上传到fir.im上-b
用fir.im测试已经好长时间了,感觉每次打包上传都很麻烦,想着是不是可以用脚本自动打包,在网上搜了一下确实有,下面总结一下如何使用脚本自动打包上传到fir.im,以及打包过程中遇到的问题和解决办法 ...
- 修改jar包内容并打包上传到私服
第一步:拉下git分支中代码,进行修改,修改后commit——>push 第二步:在IDEA中Terminal中执行命令进行打包到本地mvn clean package 第三步:上传到私服,方法 ...
- IDEA maven 项目如何上传到私服仓库
前言:idea maven 发布版本到私服(快照和正式版).我有个项目( jar 包源码),其他 maven 项目能直接引入依赖就最好了,所以必须将这个 jar 包源码发布到 maven 私服仓库里去 ...
- 使用shell脚本自动打包上传 fir.im
http://blog.csdn.net/wang631106979/article/details/52299083
- xcodebuild自动打包上传到蒲公英的shell脚本
注意: ExportOptions.plist (包含了证书相关信息) 该plist 文件可以通过xcode手动导出ipa之后获取到, 区分appstore 和 development的情况 #! / ...
- 在pom.xml中使用distributionManagement将项目打包上传到nexus私服
本文介绍 如何在pom.xml中使用distributionManagement将项目打包上传到nexus私服 1.pom.xml文件添加distributionManagement节点 <!- ...
随机推荐
- Linux内核分析——ELF文件格式分析
ELF文件(目标文件)格式主要三种: 1)可重定向文件:文件保存着代码和适当的数据,用来和其他的目标文件一起来创建一个可执行文件或者是一个共享目标文件.(目标文件或者静态库文件,即linux通常后缀为 ...
- 基于SSH框架的在线考勤系统开发的质量属性
我要开发的是一个基于SSH框架的在线考勤系统. 质量属性是指影响质量的相关因素,下面我将分别从6个系统质量属性(可用性,易用性,可修改性,性能,安全性,可测试性)来分析我的系统,以及如何实现这些质量属 ...
- 20150401 作业2 结对 四则运算ver 1.0
Web項目下 Tomcat服務器的路徑 /WebContant/ 目錄下 SE2_2.jsp <%@ page language="java" contentType=&qu ...
- 小学四则运算APP 第二阶段冲刺
第一阶段实现最基本的四则运算计算,最原始的所以还没有美化 xml文件 <LinearLayout xmlns:android="http://schemas.android.c ...
- 【Deep Hash】NINH
[CVPR 2015] Simultaneous Feature Learning and Hash Coding with Deep Neural Networks [paper] Hanjiang ...
- 关于splice()方法,slice() 、split()方法讲解,reverse()方法、replace()方法
1.slice() 方法可从已有的数组中返回选定的元素. 语法 arrayObject.slice(start,end) 参数 描述 start 必需.规定从何处开始选取.如果是负数,那么它规定从数组 ...
- mybatis批量插入和批量更新
批量插入数据使用的sql语句是: insert into table (aa,bb,cc) values(xx,xx,xx),(oo,oo,oo) mybatis中mapper.xml的代码如下: & ...
- Windows 通过命令行设置固定ip地址
Winserver1709 之后 windows系统取消了GUI界面 设置ip地址 需要使用命令行界面进行 这里简单记录一下 打开win1709的虚拟机 进入命令行控制台 输入 ipconfig 查看 ...
- 金蝶特性配置(超级BOM)
特性配置 特性物料 物料和特性的对应关系 自动新增物料的系统设置 特性物料自动新增 自动新增的特性配置方案 相关表 ICPlan_CharacteristicEntry
- MES模块
基础数据管理:产品模型.工厂模型.工艺模型 仓储管理 成本管理 绩效管理 看板管理 日志管理 设备管理:工装管理.设计器具管理.设备保养管理.设备备件管理.设备采集管理.设备点检管理.设备故障管理.设 ...