maven deploy to nexus reports error: Return code is: 401, ReasonPhrase: Unauthorized

When using the clean deploy command in eclipse to push the local file to nexus, an error is reported:

[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.

It turns out that authentication is not configured.


In the setting.xml of the maven directory conf,

quote
<servers>
<server> 
    <id>releases</id> 
    <username>admin</username> 
    <password>admin123</password> 
  </server> 
<server> 
  <id>snapshots</id> 
  <username>admin</username> 
  <password>admin123</password> 
  </server> 
</servers> 


Username and password are both nexus. Deploy again.

Note that the id here should correspond to the address of the remote deploy in pom.xml. The configuration in my pom.xml:

<!-- Configure remote publishing to private server, 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>  


If it is not configured here, an error will be reported:
Error: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

reference: http://blog.csdn.net/happyteafriends/article/details/8174110

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327017906&siteId=291194637
Recommended