首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以将工件上传到Nexus中的maven中央存储库?

是否可以将工件上传到Nexus中的maven中央存储库?
EN

Stack Overflow用户
提问于 2018-03-09 16:01:15
回答 2查看 2.6K关注 0票数 0

我正在尝试将工件上传到我在Nexus中的"maven-central“存储库。我使用的命令是:

代码语言:javascript
复制
curl -v --user admin:admin123 --upload-file /path/myjar.jar  http://nexus-nexus3.apps.lab.ca/repository/maven-central/com/tp/mycompany/1.0/myjar.jar

我发现了一个错误:

用户代理: curl/7.54.0接受:/内容长度: 560414 Expect: 100-继续HTTP/1.1 400对Maven 2存储库的无效路径日期: Fri 2018年3月9日15:54:10 GMT服务器: Nexus/3.9.0-01 (开放源码软件)

我尝试过来自sonatype文档的多个curl命令,但都没有效果。我的问题是,这可能吗?UI只允许我选择上传到maven版本和nuget托管。我怎么才能避开这一切?

EN

回答 2

Stack Overflow用户

发布于 2018-03-09 17:58:14

我不确定您是否真的想通过maven-central将专有的jars上传到开放的世界。

非常常见的做法是指定和使用maven-central和公司专用存储库的组合,托管专有的jars。你应该小心这件事的影响。

在maven中心上传一件艺术品.

要将您的工件上传到中心maven中,必须先给出这里

为什么我们有需求? 为了确保中央仓库中可用组件的最低质量,我们已经建立了一些您的部署组件必须满足的要求。这允许用户从中央存储库中提供的元数据中查找有关组件的所有相关细节。

所提出的一些要点:

  1. 供应Javadoc和源
  2. 用GPG/PGP签署文件
  3. 项目名称、描述和URL
  4. 许可证信息
  5. 开发人员信息
  6. SCM信息

完整示例下面的完整示例显示了项目和modelVersion的XML和必需元素以及示例元素和内容。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.simpligility.training</groupId>
  <artifactId>ossrh-demo</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>

  <name>ossrh-demo</name>
  <description>A demo for deployment to the Central Repository via OSSRH</description>
  <url>http://github.com/simpligility/ossrh-demo</url>

  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Manfred Moser</name>
      <email>manfred@sonatype.com</email>
      <organization>Sonatype</organization>
      <organizationUrl>http://www.sonatype.com</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/simpligility/ossrh-demo.git</connection>
    <developerConnection>scm:git:ssh://github.com:simpligility/ossrh-demo.git</developerConnection>
    <url>http://github.com/simpligility/ossrh-demo/tree/master</url>
   </scm>

...

</project>
票数 1
EN

Stack Overflow用户

发布于 2018-03-15 07:38:11

我假设默认情况下,您所调用的maven-central存储库是一个代理存储库,它镜像Maven Central。上传到代理存储库是没有意义的。您应该将您的工件上传到另一个存储库,例如maven版本,这是一个所谓的托管存储库.

您不能将工件上传到在Nexus文档中编写的代理存储库。在Nexus中创建一个单独的托管存储库(在默认情况下,已经定义了一些第三方)并将它们上传到.

您需要处理您的Nexus配置更正(显然不是这样)。您有存储库组,它将不同的存储库组合成一个逻辑存储库,用于访问(消费)工件。

要正确访问nexus组,您应该具有如下设置。给定的URL是存储库组的URL,它在Nexus中配置为使用工件。

应该将Maven中的distributionManagement配置为使用两个单独的repos,而一个是发布存储库,另一个是快照存储库。

代码语言:javascript
复制
<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49197634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档