您的位置:首页 > 其它

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

2016-07-21 20:29 651 查看
需要在maven的setting.xml中配置servers.server节点,其值为nexus的对应的repository的id以及用户名及密码

[html] view plain copy

<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

[html] view plain copy

<profiles>

<profile>

<id>xxxx</id>

<properties>

<svn.name>username</svn.name>

<svn.pwd>password</svn.pwd>

</properties>

</profile>

</profiles>

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

[html] view plain copy

<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><u><span style="color:#0066cc;">xxx.xx.xxx</span></u></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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: