web123456

Permission error occurred when deploying artifactory using Maven-deploy-plugin (maven-deploy-plugin) (401 Unauthorized)

useMavenMaven-deploy-plugin) When deploying the artifactory, a permission error occurred (401 Unauthorized): Failed to execute goal :maven-deploy-plugin:2.7:deploy (default-deploy) on project view-common: Failed to deploy artifacts: Could not transfer artifact :view-common:jar:1.1.3-20240702.024051-1 from/to snapshots (/libs-snapshots-local): Transfer failed for /libs-snapshots-local/com/jd/ad/view-common/1.1.3-SNAPSHOT/view-common-1.1.3-20240702. 401 Unauthorized -> [Help 1]

This error message indicates that the plug-in is deployed using Maven (maven-deploy-plugin) A permission error occurred when deploying the artifactory (401 Unauthorized). This means your Maven does not have the correct credentials to access the Artifactory repository.

Here are some steps to solve this problem:

1. Check

Make sure your Maven isThe file contains the correct oneserverCredentials. This file is usually located in your Maven installation directoryconfIn the directory, or in the user's.m2In the directory. Add or updateserversElement, ensuring that the correct Artifactory repository credentials are included.

<settings>
  <servers>
    <server>
      <id>snapshots</id>
      <username>your-username</username>
      <password>your-password</password>
    </server>
  </servers>
</settings>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

make sure<id>The value of the element is with youThe repository ID matches defined in.

2. Check

Make sure yoursThe repository information is correctly configured in the file.

<distributionManagement>
  <snapshotRepository>
    <id>snapshots</id>
    <url>/libs-snapshots-local</url>
  </snapshotRepository>
</distributionManagement>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3. Verify credentials

Make sure that the username and password you provide are correct and that you have permission to access and deploy to the specified Artifactory repository.

4. Check the network and firewall

Make sure your network environment allows access to the Artifactory server and there is no firewall or proxy blocking requests.

5. Update the Maven plugin version

Sometimes, deploying plug-in versions with newer Maven can solve some compatibility issues. Make sure yoursThe latest version is usedmaven-deploy-plugin

<plugin>
  <groupId></groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>2.8.2</version> <!-- or the latest version -->
</plugin>
  • 1
  • 2
  • 3
  • 4
  • 5

6. Check Artifactory configuration

Make sure the repository on the Artifactory server is configured correctly and allows deployment from your IP address.

7. Test credentials

You can test whether your credentials are correct by using curl or wget directly. For example:

curl -u your-username:your-password /libs-snapshots-local/com/jd/ad/view-common/1.1.3-SNAPSHOT/
  • 1

If 401 Unauthorized is returned, there is a problem with the credentials.

8. Clean up and try again

Sometimes, Maven's local cache can cause problems. You can try cleaning up the local repository and then rebuild and deploy.

mvn clean install
mvn deploy
  • 1
  • 2

Through these steps, you should be able to find and resolve 401 Unauthorized errors and successfully deploy your artifactory to Artifactory.