使用Maven 3返回代码401,将SNAPSHOT上传到Artifactory

时间:2013-12-26 17:09:25

标签: maven-3 artifactory

我正在运行以下内容:

Apache Maven 3.0.5,Artifactory(开源)3.1.0

No Jenkins / Hudson,只是默认的Artifactory设置。

摘自pom.xml:

<distributionManagement>
    <repository>
    <id>ServerA2</id>
    <name>ServerA2-releases</name>
    <url>http://192.168.1.16:8081/artifactory/libs-release-local</url>
    </repository>
    <snapshotRepository>
    <id>ServerA2</id>
    <name>ServerA2-snapshots</name>
    <url>http://192.168.1.16:8081/artifactory/libs-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

摘自settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>admin</username>
      <password>XXX</password>
      <id>central</id>
    </server>
    <server>
      <username>admin</username>
      <password>XXX</password>
      <id>snapshots</id>
    </server>
    <server>
      <username>admin</username>
      <password>XXX</password>
      <id>ServerA2</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://192.168.1.16:8081/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://192.168.1.16:8081/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://192.168.1.16:8081/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://192.168.1.16:8081/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

现在问题:

当我将pom.xml中的版本设置为mvn deploy时,我可以正常<version>1.0</version>。神器已成功上传

但是当我将pom.xml中的版本设置为<version>1.0-SNAPSHOT</version>

时,我遇到以下错误

mvn clean deploy -X -e

的输出
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ pinder ---
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.7:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:compile
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.0.6:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0.6:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG]   Imported:  < project>sg.com.pinder:pinder:0.0.1-SNAPSHOT
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG]   Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
[DEBUG]   Included: junit:junit:jar:3.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.6
[DEBUG]   Excluded: org.apache.maven:maven-plugin-api:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-project:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-settings:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-profile:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-artifact-manager:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-repository-metadata:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-plugin-registry:jar:2.0.6
[DEBUG]   Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1
[DEBUG]   Excluded: classworlds:classworlds:jar:1.1-alpha-2
[DEBUG]   Excluded: org.apache.maven:maven-model:jar:2.0.6
[DEBUG]   Excluded: org.apache.maven:maven-artifact:jar:2.0.6
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7, parent: sun.misc.Launcher$AppClassLoader@645ad7b2]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator -->
[DEBUG]   (f) artifact = sg.com.pinder:pinder:jar:0.0.1-SNAPSHOT
[DEBUG]   (f) attachedArtifacts = []
[DEBUG]   (s) localRepository =        id: local
      url: file:///home/Eric_Vader/.m2/repository/
   layout: none

[DEBUG]   (f) offline = false
[DEBUG]   (f) packaging = jar
[DEBUG]   (f) pomFile = /home/Eric_Vader/workspace/pinder/pom.xml
[DEBUG]   (f) project = MavenProject: sg.com.pinder:pinder:0.0.1-SNAPSHOT @ /home/Eric_Vader/workspace/pinder/pom.xml
[DEBUG]   (f) retryFailedDeploymentCount = 1
[DEBUG]   (f) skip = false
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.1.16:8081/artifactory/libs-snapshot-local as admin
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder:0.0.1-SNAPSHOT/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/0.0.1-SNAPSHOT/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.000s
[INFO] Finished at: Fri Dec 27 16:48:15 SGT 2013
[INFO] Final Memory: 18M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project pinder: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project pinder: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
    ... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    ... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:939)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
    ... 26 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
    at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:257)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:423)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:402)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:376)
    at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:811)
    ... 28 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

摘自access.log:

2013-12-27 16:48:15,328 [DENIED DEPLOY] libs-snapshot-local:sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar for anonymous/192.168.1.164.
2013-12-27 16:48:15,335 [DENIED DEPLOY] libs-snapshot-local:sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.pom for anonymous/192.168.1.164.

我尝试了其他类似问题建议的大部分内容,例如: 尝试在settings.xml中设置Maven Snapshot Version Behavior设置snapshot标记。

需要注意的一点是,Artbersory服务器上的日志在发生错误时不会记录任何内容。

4 个答案:

答案 0 :(得分:4)

这就是正在发生的事情 - 您在ID central下有2个存储库 - libs-release-localdistributionManagement}和libs-releasesettings)。 snapshots也是如此。 这使得Maven以一些无法预测的方式疯狂(Maven很好)。

因此,在central中隐藏snapshotssettings是正确的方法,但distributionManagement中的存储库应该以不同的方式调用。我建议你从Artifactory中的存储库页面复制相应的片段: enter image description here

答案 1 :(得分:2)

好的,我已经找到了解决方法。

转到端口8081的Artifactory管理页面(默认)导航至: 管理员 - &gt;安全 - &gt;一般

确保旁边的复选框 Allow Anonymous Access

未经检查。

接下来,请确保您在settings.xml中拥有相应的登录信息,以访问您的存储库以进行读写访问。

这样做可以解决这个问题。 欢呼声。

[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.1.16:8081/artifactory/libs-snapshot-local as admin
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder:0.0.1-SNAPSHOT/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/0.0.1-SNAPSHOT/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.jar
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.jar (2 KB at 11.1 KB/sec)
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.pom
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.pom (2 KB at 18.4 KB/sec)
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml (769 B at 8.3 KB/sec)
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml (279 B at 3.0 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.890s
[INFO] Finished at: Wed Jan 01 14:51:27 SGT 2014
[INFO] Final Memory: 11M/216M
[INFO] ------------------------------------------------------------------------

答案 2 :(得分:0)

我有类似的错误,但是由maven-source-plugin引起。解决方法是删除&#34;执行&#34;从孩子pom。看起来有些问题与jar和jar-no-fork运行两次。我按照以下方式解决了这个问题:

左父母pom

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-source-plugin</artifactId>
  <version>2.1.2</version>
  <executions>
    <execution>
      <id>attach-sources</id>
      <goals>
        <goal>jar</goal>
      </goals>
    </execution>
  </executions>
</plugin>

并改变了儿童pom:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
            <execution>
                <id>attach-sources</id>
                <goals>
                    <goal>jar-no-fork</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

到:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
  </plugin>

答案 3 :(得分:0)

在Web UI中,转到function manipulateItem (item, add) { const { element, index } = item; element.classList.toggle('active', add); this.items[index - 1].element.classList.toggle('active-sibling', add); this.items[index + 1].element.classList.toggle('active-sibling', add); } if (this.previousActiveItem) { manipulateItem(this.previousActiveItem, false); } manipulateItem(this.activeItem, true); 。 输入要解锁的密码。

复制加密密码。 enter image description here

http://ip:8081/artifactory/webapp/#/profile的{​​{1}}中的

设置加密的密码,不带“。

我的问题通过这种方式解决了。