Java 存储库元素未在 distributionManagement 元素内的 POM 或 -DaltDep loymentRepository=id::layout::url 参数中指定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27153024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 03:54:33  来源:igfitidea点击:

repository element was not specified in the POM inside distributionManagement element or in -DaltDep loymentRepository=id::layout::url parameter

javamavendeploymentpom.xml

提问by Mertcan

I'm having a problem while deploying and here is the error message I get:

我在部署时遇到问题,这是我收到的错误消息:

[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ core ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.296 s
[INFO] Finished at: 2014-11-26T17:05:00+02:00
[INFO] Final Memory: 13M/244M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy (default-deploy) on project core: Deployment failed: repository element w
as not specified in the POM inside distributionManagement element or in -DaltDep
loymentRepository=id::layout::url parameter -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

I checked some resources on the internet and none of them worked for my case. I think it's related to my pom.xml, so here are its related parts:

我检查了互联网上的一些资源,但没有一个对我的案例有效。我认为它与 my 相关pom.xml,所以这里是它的相关部分:

<build>
        <plugins>
              <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                         <source>1.7</source>
                         <target>1.7</target>
                    </configuration>
              </plugin>
        </plugins>
  </build>

  <repositories>
        <repository>
              <id>repository.springframework.maven.release</id>
              <name>Spring Framework Maven Release Repository</name>
              <url>http://maven.springframework.org/release</url>
        </repository>
        <repository>
              <id>Appid</id>
              <name>AppName</name>
              <url>http://IPaddress/nexus/content/repositories/Myapps/</url>
        </repository>
  </repositories>

What do you think the problem might be? Thanks in advance.

你认为问题可能是什么?提前致谢。

采纳答案by jchampemont

You should include the repository where you want to deploy in the distribution management section of the pom.xml.

您应该在pom.xml.

Example:

例子:

<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">
...   
<distributionManagement>
    <repository>
      <uniqueVersion>false</uniqueVersion>
      <id>corp1</id>
      <name>Corporate Repository</name>
      <url>scp://repo/maven2</url>
      <layout>default</layout>
    </repository>
    ...
</distributionManagement>
...
</project>

See Distribution Management

分销管理

回答by Thara Perera

In your pom.xml you should add distributionManagement configuration to where to deploy.

在您的 pom.xml 中,您应该将 distributionManagement 配置添加到要部署的位置。

In the following example I have used file system as the locations.

在以下示例中,我使用文件系统作为位置。

<distributionManagement>
       <repository>
         <id>internal.repo</id>
         <name>Internal repo</name>
         <url>file:///home/thara/testesb/in</url>
       </repository>
   </distributionManagement>

you can add another location while deployment by using the following command (but to avoid above error you should have at least 1 repository configured) :

您可以使用以下命令在部署时添加另一个位置(但为了避免上述错误,您应该至少配置 1 个存储库):

mvn deploy -DaltDeploymentRepository=internal.repo::default::file:///home/thara/testesb/in

回答by 2787184

The issue is fixed by adding repository url under distributionManagement tab in main pom.xml.

通过在主 pom.xml 中的 distributionManagement 选项卡下添加存储库 url 来修复该问题。

Jenkin maven goal : clean deploy -U -Dmaven.test.skip=true

Jenkin maven 目标:干净部署 -U -Dmaven.test.skip=true

<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://domain:port/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <url>http://domain:port/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>