【问题标题】:Uploading Jersey jars to local artifactory将泽西罐子上传到本地工件
【发布时间】:2015-04-20 02:23:53
【问题描述】:

我已经尝试了将近一天,使用 Maven 将 jar 文件从 Jersey 部署到我们本地的 Artifactory。我对泽西岛的branch 2.6.x 做了一些小改动,并构建并打包了罐子。以下是来自 Jersey 的父 pom 的摘录:

<groupId>org.glassfish.jersey</groupId>
<artifactId>project</artifactId>
<packaging>pom</packaging>
<version>2.6.rn-SNAPSHOT</version>
<name>jersey</name>
<description>
    Jersey is the open source (under dual CDDL+GPL license) JAX-RS 2.0 (JSR 339)
    production quality Reference Implementation for building RESTful Web services.
</description>

<distributionManagement>
    <repository>
        <id>central</id>
        <name>central-repo</name>
        <url>http://localhost/artifactory/libs-releases-local</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>central-repo-snapshots</name>
        <url>http://localhost/artifactory/libs-snapshots-local</url>
    </snapshotRepository>
</distributionManagement>

我的settings.xml由artifactory生成并放在~/.m2/settings.xml

但是当我尝试使用 mvn deploy 进行部署时,我得到以下信息:

Uploading: (https: //maven.java.net/content/repositories/snapshots/):
Failed to transfer file: https://maven.java.net/content/repositories/snapshots/org/glassfish/jersey/project/2.6.rn-SNAPSHOT/project-2.6.rn-20150218.212627-1.pom.
Return code is: 401, ReasonPhrase: Unauthorized.

我的完整 settings.xml 如下所示:

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

【问题讨论】:

  • 当您尝试上传工件时,通常需要用户名和密码(有权上传工件)。 This 可以帮到你。
  • 感谢您的回复。问题是它不应该首先尝试上传到该存储库(它正在尝试上传到 maven.java.net)而不是上传到我的本地工件)
  • 哦,对不起。没读那个。我设置了一个新项目并将您提供的配置添加到我的 pom.xml 中。在 settings.xml 中没有任何更改的情况下,maven 尝试联系分发管理内的服务器。这意味着您的失败可能取决于其他因素。你使用个人资料吗?或者你可能有一个带有父 pom 的 pom 结构?
  • 在artifactory生成的设置中,尝试将repositories id从central切换到something-centralsnapshots切换到something-snapshots
  • @Jan 是的,这是我在页面顶部喜欢的整个球衣项目,所以有一个父 pom 和数百万个小 pom。我已将 distributionManagement 标签添加到我的父 pom.xml 中。我应该只将它添加到我想要部署的那些 pom 中吗?

标签: java maven jersey-2.0 artifactory


【解决方案1】:

您必须在 pom.xml 中添加 distributionManagement 标记,其中 url 将是您的 Artifactory 的 url,并在 settings.xml 中添加凭据

您可以阅读有关此here 的更多信息。

【讨论】:

    猜你喜欢
    • 2012-06-23
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 2015-03-07
    • 2012-07-20
    • 1970-01-01
    相关资源
    最近更新 更多