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内核及分析 第一周 计算机是如何工作的?
C语言代码: int g(int x) { return x + 5; } int f(int x) { return g(x); } int main(void) { return f(5) + 1 ...
- <<梦断代码>>阅读笔记二
这是第二篇读书笔记,这本书我已经读了有一大半了,感觉书中所描述的人都是疯子,一群有创造力,却又耐得住寂寞的疯子. 我从书中发现几点我比较感兴趣的内容. 第一个,乐高之梦.将程序用乐高积木一样拼接起来. ...
- JAVA面对对象(四)——抽象类
抽象类的作用类似“模板”,可以根据它的格式来修改.创建新的类:但是不能直接由抽象类创建对象只能通过抽象类派生出新的类,再由它来创建对象:抽象类的使用同样是单继承,即一个子类只能继承一个抽象类 抽象类的 ...
- corosync+pacemaker的crmsh的常用指令介绍
配置crmsh的yum仓库,此仓库的RPM包有openSUSE提供,将这个network:ha-clustering:Stable.repo文件直接下载到本地并且命名为crmsh.repo wget ...
- Win2012r2 以及win2016 安装.NET3.5
自从微软的内核 6.2以上的版本之后 win2012 win2016 已经自带了 .net4.0的版本 但是很多应用还需要.net 3.5的版本,虽然微软的安装盘里面有 .net 3.5的安装文件,但 ...
- number (2)变量相关错误
变量没有被定义 fw cannot be resolved 变量没有被初始化 正确代码 package com.itheima_01; import java.io.FileWriter;import ...
- CSS 选择器继承和层叠
CSS选择器及其继承特性.层叠特性1.基本选择器 标记 id class 这个就不再作介绍了 2.复合选择器 交集 交集选择器由两个选择器直接连接构成,其结果是选中二者各自元素范围的交集 其 ...
- Delphi的关键字
Constructor;构造器,定义构造函数使用Constructor关键字
- AWS、Azure和Google的云容器注册表有什么区别?
亚马逊云计算服务(AWS).谷歌云服务和微软Azure,这三大公共云平台都提供Docker容器注册表.虽然他们的产品看起来很相似,但开发人员在做出选择之前,应该先了解价格和功能方面的差异. 公共云供应 ...
- Scala常用命令
:q 退出控制台 控制台换行 空格 + 回车