繁体   English   中英

为什么在我尝试部署到本地 sonatype maven 存储库时 `maven clean deploy` 失败?

[英]Why is `maven clean deploy` failing while I am trying to deploy to a local sonatype maven repo?

我正在尝试设置一个 Sonatype Maven Artefacts 私有存储库。

My.m2/settings.xml 如下所示

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:10081/repository/maven-tarkshala/</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>
  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>tarkshala</password> 
    </server>
  </servers>
</settings>

我的项目的 pom 看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright © 2019 Federico Recio (N/A)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.smoketurner.dropwizard</groupId>
        <artifactId>dropwizard-pom</artifactId>
        <version>2.0.16-1</version>
    </parent>

    <groupId>com.tarkshala</groupId>
    <artifactId>dropwizard-swagger</artifactId>
    <version>2.0.16</version>

    <properties>
        <jersey.version>2.35</jersey.version>
        <swagger.version>2.2.7</swagger.version>
    </properties>

    <name>Dropwizard Swagger support</name>
    <description>A simple way to document your REST APIs in DropWizard using Swagger</description>
    <url>https://github.com/smoketurner/dropwizard-swagger/</url>

    <developers>
        <developer>
            <name>Federico Recio</name>
            <url>http://about.me/federecio</url>
        </developer>
        <developer>
            <id>jplock</id>
            <name>Justin Plock</name>
            <email>jplock@smoketurner.com</email>
            <timezone>America/New_York</timezone>
        </developer>
    </developers>

    <!-- Used to point local artifacts to the hosted repo , Starts  -->
    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>maven-releases</name>
            <url>http://localhost:10081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>maven-snapshots</name>
            <url>http://localhost:10081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <!--  Ends  -->

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey.containers</groupId>
                <artifactId>jersey-container-servlet-core</artifactId>
                <version>${jersey.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-auth</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-assets</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-views</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-views-freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-integration</artifactId>
            <version>${swagger.version}</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>2.3.3</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <version>1.2.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.5.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <properties>
                        <owner>Federico Recio</owner>
                        <email>N/A</email>
                    </properties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>nexus</serverId>
                    <nexusUrl>http://localhost:10081/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

如果我将版本更改为像<version>2.0.16-SNAPSHOT</version> ,它可以很好地构建和部署。 我可以在我的存储库中验证相同的内容以及显示的内容。

快照版本的存储库屏幕截图

构建日志看起来也不错,如下所示:

[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) @ dropwizard-swagger ---
[INFO] Performing deferred deploys (gathering into "/Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred")...
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT.jar
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/pom.xml to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT.pom
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT-sources.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT-sources.jar
[INFO] Installing /Users/apple/Work/repos/dropwizard-swagger/target/dropwizard-swagger-2.0.16-SNAPSHOT-javadoc.jar to /Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/deferred/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-SNAPSHOT-javadoc.jar
[INFO] Deploying remotely...
[INFO] Bulk deploying locally gathered artifacts from directory: 
[INFO]  * Bulk deploying locally gathered snapshot artifacts
Downloading from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-javadoc.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-javadoc.jar (370 kB at 3.3 MB/s)
Downloading from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml
Downloaded from nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml (294 B at 12 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (651 B at 12 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/maven-metadata.xml (335 B at 4.6 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.jar (2.6 MB at 16 MB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.pom
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1.pom (6.0 kB at 122 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (999 B at 17 kB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-sources.jar
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/dropwizard-swagger-2.0.16-20230108.025513-1-sources.jar (2.6 MB at 14 MB/s)
Uploading to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml
Uploaded to nexus: http://localhost:10081/repository/maven-snapshots/com/tarkshala/dropwizard-swagger/2.0.16-SNAPSHOT/maven-metadata.xml (1.2 kB at 25 kB/s)
[INFO]  * Bulk deploy of locally gathered snapshot artifacts finished.
[INFO] Remote deploy finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.868 s
[INFO] Finished at: 2023-01-08T08:25:29+05:30
[INFO] ------------------------------------------------------------------------

但是当我将版本更改为像<version>2.0.16</version>发布时。 命令mvn clean deploy失败并出现以下错误

[INFO] 
[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) @ dropwizard-swagger ---
[INFO] Performing local staging (local stagingDirectory="/Users/apple/Work/repos/dropwizard-swagger/target/nexus-staging/staging")...
[INFO]  + Using server credentials "nexus" from Maven settings.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.436 s
[INFO] Finished at: 2023-01-08T08:12:56+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project dropwizard-swagger: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy failed: Nexus connection problem to URL [http://localhost:10081/ ]: 404 - Not Found -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/PluginExecutionException

看起来您正在使用 Nexus 暂存 maven 插件进行部署。 但是您没有使用具有暂存支持的 Nexus Professional,并且没有为此正确设置 URL。

要修复它,请将 distributionManagement 中的 URL 更改为指向暂存 URL,或者删除暂存插件的使用并使用正常的部署插件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM