maven release插件将一版本发布到仓库中时Return code is: 401, ReasonPhrase:Unauthorized

需要在maven的setting.xml中配置servers.server节点,其值为nexus的对应的repository的id以及用户名及密码

<servers>	
	<server>
		<id>releases</id>
		<username>admin</username>
		<password>admin</password>
	</server>
	<server>
  		<id>snapshots</id>
  		<username>deployment</username>
  		<password>deployment</password>
	</server>
</servers>

mvn release:prepare -Pxxxx 将用setting.xml中定义的profile为我们提交,打tag,升级pom,再提交的一连串动作(但不要忘了setting.xml的profile定义及pom.xm中定义好maven-release-plugin的tagBase,username,password以及每个模块的scm信息)

maven conf/setting.xml

<profiles>
	<profile>
		<id>xxxx</id>
		<properties>
			<svn.name>username</svn.name>
			<svn.pwd>password</svn.pwd>
		</properties>
	</profile>
</profiles>

项目 pom.xml (让子模块都继承自另一个模块,类型为pom,假定名称为parent)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>xxx.xx.xxx</groupId>
		<artifactId>xxxx</artifactId>
		<version>0.3-SNAPSHOT</version>
	</parent>
	<groupId>xxx.xx.xxx</groupId>
	<artifactId>parent</artifactId>
	<name>parent</name>
	<packaging>pom</packaging>
	<scm>
		<connection>scm:svn:https://192.168.1.88/svn/xxxx/trunk/parent</connection>
		<url>https://192.168.1.88/svn/xxxx/trunk/parent</url>
	</scm>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<configuration>
					<tagBase>https://192.168.1.88/svn/xxxx/tags/</tagBase>
					<username>${svn.name}</username>
					<password>${svn.pwd}</password>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>




这样mvn release:perform时maven-release-plugin会自动帮我们签出刚才打的tag,然后打包,分发到远程Maven仓库中(nexus).

注意:如果要把快照版本也发布到存储库,需要在trunk中执行mvn deploy,并且一定要配置snapshotRepository


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值