Maven:无法部署工件,Acces被拒绝

Tim*_*Tim 6 nexus maven

我有一个Sonatype Nexus服务器,我想部署一个快照.

这是我的settings.xml文件的片段:

<servers>
  <server>
    <id>test-snapshots</id>
    <username>myname1</username>
    <password>mypasswd1</password>
  </server>
  <server>
    <id>test-releases</id>
    <username>myname2</username>
    <password>mypasswd2</password>
  </server>
</servers>
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml文件的片段:

<distributionManagement>
  <repository>
    <id>test-releases</id>
    <name>Releases</name>
    <url>https://nxs.company.com/content/repositories/test-releases</url>
  </repository>
  <snapshotRepository>
    <id>test-snapshots</id>
    <name>Snapshots</name>
    <url>https://nxs.company.com/content/repositories/test-snapshots</url>
  </snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

做一个mvn deploy(Maven 3.0.3)我收到这个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy 
(default-deploy) on project MyProject: Failed to deploy artifacts: 
Could not transfer artifact com.company.project:MyProject:jar:1.0.0-20121003.154427-1 
from/to test-snapshots (https://nxs.company.com/content/repositories/test-snapshots): 
Access denied to: https://nxs.company.com/content/repositories/test-snapshots/
com.company.project/MyProject/1.0.0-SNAPSHOT/MyProject-1.0.0-20121003.154427-1.jar
-> [Help 1]
Run Code Online (Sandbox Code Playgroud)

在我的Nexus日志文件中,我看到没有收到任何凭据,因此稍后会以匿名方式进行尝试,这当然会失败.那么为什么没有凭证传递给Nexus?

2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.apache.shiro.session.mgt.DefaultSessionManager - Unable to resolve session ID from SessionKey [org.apache.shiro.web.session.mgt.WebSessionKey@791a17dc].  Returning null to indicate a session could not be found.
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - Attempting to authenticate Subject as Anonymous request...
2012-10-04 17:24:14 DEBUG [1027496148-8353] - org.sonatype.security.ldap.realms.DefaultLdapContextFactory - Initializing LDAP context using URL [ldap://10.100.100.1:3268/DC=company,DC=com] and username [ldap@company.com] with pooling [enabled]
Run Code Online (Sandbox Code Playgroud)

Bri*_*Fox 1

Nexus 中的每个存储库真的有不同的用户名/密码吗?这将导致 maven http wagon 出现问题,因为 jvm 缓存每个主机的凭据,即使 maven 正确地提供了备用凭据,jvm 也不会使用它们。解决方法是使用 webdav wagon,因为它使用 apache http 客户端而不是 jdk urlclient。