错误未能在项目上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (默认部署)。未能部署工件:无法传输artifactReturn代码是: 401,ReasonPhrase:未经授权。->帮助1
自上一次成功构建以来,没有进行任何更改。我再次检查settings.xml(用户名和密码).Also签入pom.xml(分发管理)
我从过去的两天开始研究这个问题,我浏览了所有的论坛,没有任何works.please帮助我。
发布于 2018-02-02 17:13:43
此错误消息意味着您的计算机没有对Nexus计算机进行正确的身份验证。从Maven发送给Nexus的凭据是不正确的。
当我收到这条消息时,我通常需要查看我的settings.xml来验证这个部分的正确凭证。用户名和密码必须是正确的设置在Nexus本身。
<servers>
<server>
<id>nexus-releases</id>
<username>fillin</username>
<password>fillin</password>
</server>
</servers>我通常使用Nexus并尝试使用这些凭据登录来验证它们,但是可以配置凭据,这些凭据可以通过mvn发布,但不能登录到GUI中。
一个可能的问题是,如果您使用依赖关系管理来确定在"mvn部署“目标情况下部署到哪里。有这样的一节:
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>releases</name>
<url>http://myNexus/more/stuff</url>
</repository>
</distributionManagement>并且id字段必须与settings.xml中凭据上的id匹配。如果ids不匹配,您将得到此错误。
另一个可能的问题是,如果在pom.xml中使用maven-deply-plugin的执行,则可能具有配置属性。
<repositoryId>nexus-releases</repositoryId> 同样,它与settings.xml中的id不匹配,因此它会因错误而失败。
类似地,如果在"mvn“命令上使用命令行选项进行部署,则如下所示
-DrepositoryId=nexus-releases与settings.xml中的id不匹配,同样,它将无法工作。
发布于 2016-05-17 07:54:19
在注释部分讨论之后,尝试运行此pom.xml
当mvn的目标应该是:mvn部署
唯一需要的两件事是拥有一个pom并传递参数:
这是您可以使用的pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hp.Maven</groupId>
<artifactId>Maven-Nexus</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<properties>
<baseNexusURL>${baseNexusURL}</baseNexusURL>
<targetRepositoryID>${repositoryId}</targetRepositoryID>
<package.final.name>${project.artifactId}</package.final.name>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>deploy-node-modules-artifact</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>${file}</file>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>${packaging}</packaging>
<generatePom>true</generatePom>
<repositoryId>${targetRepositoryID}</repositoryId>
<url>${baseNexusURL}/content/repositories/${targetRepositoryID}</url>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

https://stackoverflow.com/questions/37126573
复制相似问题