相关疑难解决方法(0)

在Nexus中部署工件时出错

我在Nexus服务器的自己的存储库中部署工件时遇到错误:"无法部署工件:无法传输工件""无法传输文件http:/// my_artifact.返回代码为:400"

我让Nexus运行了一个自定义存储库my_repo和下一个maven本地配置:

的settings.xml

<server>
    <id>my_repo</id>
    <username>user</username>
    <password>pass</password>
 </server>
 ...
 <mirror>
    <id>my_repo</id>
    <name>Repo Mirror</name>
    <url><my_url_to_my_repo></url>
    <mirrorOf>*</mirrorOf>
  </mirror>
Run Code Online (Sandbox Code Playgroud)
  • 用户有权创建/读取/写入my_repo -

的pom.xml

<distributionManagement>
        <repository>
            <id>my_repo</id>
            <name>my_repo</name>
            <url><my_url_to_my_repo></url>
            <layout>default</layout>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url><my_url_to_my_snapshot_repo></url>
        </snapshotRepository>
    </distributionManagement>
Run Code Online (Sandbox Code Playgroud)

然后我执行

mvn deploy
Run Code Online (Sandbox Code Playgroud)

并得到错误.任何的想法?

deployment nexus pom.xml maven

90
推荐指数
6
解决办法
13万
查看次数

Nexus接受上传,但表示失败了

当我mvn release:perform在父POM上执行时,服务器正在响应有关其中一个子项目(文件名已编辑)的错误:

[错误]无法在项目上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file(default-cli):无法部署工件:无法将工件从/向存储库传输:无法转移文件.返回码为:400,ReasonPhrase:错误请求.

但是,此子项目的所有文件都已成功上载!我看到一个新目录(以发行版本号命名),它包含了人们所期望的所有.jar,.pom,.md5和.sha1文件.

我无法访问Nexus服务器,但我想知道是什么原因造成的,以及如何解决它.是否有可能Maven试图两次上传这个特定的子项目?如果是这样,为什么Maven会这样做,我怎么能阻止它呢?

更新:如果你有同样的问题,请与最upvotes答案这个职位.我跑了mvn help:effective-pom,发现有问题的项目实际上有两次部署阶段的执行.删除其中一个执行解决了我的问题.

java nexus maven

22
推荐指数
1
解决办法
2万
查看次数

maven-assembly-plugin:如何使用appendAssemblyId

我有一个多模块Maven项目,在一个模块中我想在构建期间创建两个工件:

  • 主要工件是一个jar库,其他一些模块将依赖于它.
  • 一个执行一些辅助函数的可执行jar文件.没有其他模块依赖于此,它仅供用户在某些情况下手动运行.

这是我用来配置maven-assembly-plugin插件的代码:

<plugin>
    <artifactId>
        maven-assembly-plugin
    </artifactId>
    <version>2.4</version>
    <executions>
      <execution>
        <id>dist-assembly</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>

        <configuration>
          <finalName>bso</finalName>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <finalName>helper-${project.version}</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <archive>
            <manifest>
              <mainClass>HelperMain<mainClass>
            </manifest>
          </archive>
        </configuration>

      </execution>
    </executions>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

我正在设置appendAssemblyId,false因为否则-jar-with-dependencies将附加到最终名称,我不认为有必要.省略它可以提供更清晰,更易于使用的文件名.

当我跑步时,mvn integration-test我收到以下警告:

[警告]配置选项:'appendAssemblyId'设置为false,并且缺少'classifier'.它不会附加汇编文件:[...]/target/helper-5.0.0-SNAPSHOT.jar,而是成为主项目工件的文件.

注意:如果为此项目提供了多个描述符或描述符格式,则此文件的值将是不确定的!

[警告]用程序集文件替换预先存在的项目主工件文件:[...]/target/my.module-5.0.0-SNAPSHOT.jar:[...]/target/helper-5.0.0- SNAPSHOT.jar

有两件事激怒了我:

  1. 尽管警告声称它将用helper-5.0.0-SNAPSHOT.jar替换my.module-5.0.0-SNAPSHOT.jar,但它实际上并没有这样做,并且当构建完成时,两个文件仍然具有不同的大小.

  2. 为什么有关更换工件的警告出现?

  3. 似乎classifier已弃用为什么警告要求我使用它?

java maven maven-assembly-plugin

21
推荐指数
1
解决办法
1万
查看次数

Maven maven-deploy-plugin总是上传两次

将组件发布到Nexus存储库时遇到问题,Maven上传文件两次:

  • 第一次使用maven-deploy-plugin groupId/artifactId/version参数(这就是我想要的)
  • 第二次使用pom groupId/artifactId/version参数(这是我不想要的)

我使用以下命令启动打包/部署(请参阅底部的pom.xml文件):

mvn clean package deploy:deploy-file -e -f pom.xml

这是处理部署阶段时maven输出控制台的片段(6个第一行是正确的,但注意到最后两行有pom groupId/artifactId/version):

[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) @ assemblage-playbook ---
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/1.0/COMPOSANT-A_1.0.tar.gz
Uploaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/1.0/COMPOSANT-A_1.0.tar.gz (2 KB at 2.7 KB/sec)
Downloading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml
Downloaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml (321 B at 4.6 KB/sec)
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml
Uploaded: http://urlRepo:8080/nexus/content/repositories/snapshots/COMPOSANTS/COMPOSANT-A/maven-metadata.xml (321 B at 1.6 KB/sec)
Downloading: http://urlRepo:8080/nexus/content/repositories/snapshots/com/com.mycompany/assemblage-playbook/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://urlRepo:8080/nexus/content/repositories/snapshots/com/com.mycompany/assemblage-playbook/1.0-SNAPSHOT/assemblage-playbook-1.0-20150209.154427
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml文件:

<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>assemblage-playbook</artifactId>
    <packaging>pom</packaging>
    <name>assemblage-playbook</name>

    <parent>
        <groupId>com.mycompany</groupId>
        <artifactId>parent</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../../../parent/pom.xml</relativePath>
    </parent>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly/playbook-assembly.xml</descriptor>
                    </descriptors>
                    <finalName>COMPOSANT-A-1.0</finalName> …
Run Code Online (Sandbox Code Playgroud)

maven maven-deploy-plugin

12
推荐指数
1
解决办法
7268
查看次数

Maven阶段执行两次

我需要生成一些源代码,因此我将插件目标附加到generate-sources生命周期阶段.

当我运行mvn包它工作正常,但是当我运行mvn install时,我注意到我的源生成插件执行了两次.

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>generate-sources-id</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <tasks>
                            <property name="build.compiler" value="extJavac" />

                            <ant target="generate-sources-from-ant" />
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

有什么想法来解决这个问题吗?

plugins phase maven

11
推荐指数
1
解决办法
9392
查看次数

是否可以覆盖maven pluginManagement中的执行?

在父母POM中,我有:

 <pluginManagement>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                       <id>execution 1</id>
                       ...
                    </execution>
                    <execution>
                       <id>execution 2</id>
                       ...
                    </execution>
                    <execution>
                       <id>execution 3</id>
                       ...
                    </execution>
                </executions>
            </plugin>
        <pluginManagement>
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 是否可以<execution>在子项目中禁用某些项目,例如,仅运行execution 3并跳过1和2?
  2. 是否有可能完全覆盖子项目中的执行,例如我exection 4在子项目中有一个,我只想运行它,execution并且永远不会在父POM中运行执行1,2,3.

maven

9
推荐指数
1
解决办法
5985
查看次数

maven deploy + nexus因错误请求而失败

我在构建过程中遇到了一些问题.

构建完成正常,Jenkins开始将文件上传到nexus.一切运作良好,但由于某种原因它失败了,最奇怪的部分是提到不上传的文件实际上传,我可以在nexus中找到它.

这是输出:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] pn-parent
[INFO] pn-domain
[INFO] pn-infra
[INFO] pn-config
[INFO] datalink-repository
[INFO] pn-service
[INFO] pn-backend
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building pn-parent 0.0.707
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:pom:4.11 has been relocated to junit:junit:pom:4.11
[INFO] 
[INFO] --- maven-jar-plugin:2.5:jar (default-cli) @ pn-parent ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /var/lib/jenkins/jobs/webapps-server-side-release/workspace/pn-parent/target/pn-parent-0.0.707.jar
[INFO] 
[INFO] …
Run Code Online (Sandbox Code Playgroud)

build nexus maven jenkins

7
推荐指数
1
解决办法
2万
查看次数

Maven插件在构建期间执行多次

我有一个Maven项目,有多个重叠的配置文件.我想在每个构建开始时显示活动的配置文件.所以我将以下内容放入该pom.xml <build>部分:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-help-plugin</artifactId>
    <version>2.1.1</version>
    <executions>
        <execution>
            <id>display-active-profiles-at-start-of-build</id>
            <phase>validate</phase>
            <goals>
                <goal>active-profiles</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

问题是插件在构建期间执行多次:

  1. 在构建开始时(在validate阶段期间).
  2. jar:jar执行.
  3. source:jar/ pre-integration-test?(?)之后,当Jetty正在启动时.

指定时的结果类似<phase>initialize</phase>.有没有办法让它只在构建开始时运行?

maven-2 maven-plugin maven

6
推荐指数
1
解决办法
2815
查看次数

Maven 尝试两次部署同一个工件

我正在使用 Maven 来构建我的项目,但是当我运行命令时mvn clean package deploy,它会尝试部署工件两次。我将 build-helper-maven-plugin 插件配置为附加我使用自定义插件创建的 ear 文件。

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.9.1</version>
            <executions>
                <execution>
                    <id>attach-artifacts</id>
                    <phase>package</phase>
                    <goals>
                        <goal>attach-artifact</goal>
                    </goals>
                    <configuration>
                        <artifacts>
                            <artifact>
                                <file>${project.build.directory}/${project.artifactId}-${project.version}.ear</file>
                                <type>ear</type>
                            </artifact>
                        </artifacts>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

当我禁用 build-helper-maven-plugin 时,剩余的工件(仅 pom)仅上传一次。

我应该怎么做才能让 Maven 只部署一次额外的 ear 文件?

埃特斯

编辑

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.group.id</groupId>
    <artifactId>my.artifact.id</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>My Project</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <scm>
        <!-- Config -->
    </scm>

    <distributionManagement>
        <repository>
            <!-- Config -->
        </repository>
        <snapshotRepository>
            <!-- Config -->
        </snapshotRepository>
    </distributionManagement> …
Run Code Online (Sandbox Code Playgroud)

java maven

2
推荐指数
1
解决办法
4469
查看次数

maven部署上传旧版本和当前版本

我已经检查过问题但无济于事,而且我的项目不是多模块maven项目。pom.xml文件

问题

我的项目版本是 5.5,我正在尝试将其部署到 Maven 存储库。但mvn ddeploy失败并出现以下错误 -

[ERROR] 
[ERROR] Nexus Staging Rules Failure Report
[ERROR] ==================================
[ERROR] 
[ERROR] Repository "comseleniumtests-1056" failures
[ERROR]   Rule "RepositoryWritePolicy" failures
[ERROR]     * Artifact updating: Repository ='releases:Releases' 
does not allow updating artifact='/com/seleniumtests/seleniumtestsframework/5.4/seleniumtestsframework-5.4-sources.jar'
[ERROR]     * Artifact updating: Repository ='releases:Releases' does not allow updating artifact='/com/seleniumtests/seleniumtestsframework/5.4/seleniumtestsframework-5.4-javadoc.jar'
[ERROR]     * Artifact updating: Repository ='releases:Releases' does not allow updating artifact='/com/seleniumtests/seleniumtestsframework/5.4/seleniumtestsframework-5.4.pom'
[ERROR]     * Artifact updating: Repository ='releases:Releases' does not allow updating artifact='/com/seleniumtests/seleniumtestsframework/5.4/seleniumtestsframework-5.4.jar'
[ERROR] 
[ERROR] 
Run Code Online (Sandbox Code Playgroud)

Apache …

java maven

1
推荐指数
1
解决办法
1151
查看次数