gpt4 book ai didi

java - 如何使用 Maven 部署多项目?

转载 作者:行者123 更新时间:2023-11-28 22:58:41 24 4
gpt4 key购买 nike

我想用父 pom 部署几个 java 项目。我的树是:

pom.xml
└── /project 1
└── pom.xml
└── /project 2
└── pom.xml

为了不重复代码,我想在父 pom 中编写以部署我的应用程序:

    <distributionManagement>
<repository>
<id>myName</id>
<url>scp://myURL</url>
</repository>
</distributionManagement>

        <extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>

当我使用命令“mvn deploy”时:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project project1: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [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/MojoExecutionException

提前致谢!

最佳答案

请仔细阅读并尝试一下...在 paernt pom 中添加模块标签,比如

<modules>
<module>../ChildProjec1</module>
<module>../ChildProjec2</module>
<module>../ChildProjec3</module>
</modules>

并在父POM中添加'parent'标签

<parent>
<relativePath>../ParentProject1/</relativePath>
<groupId>soemthing..</groupId>
<artifactId>soemthing..</artifactId>
<version>1.0.0.0</version>
</parent>

请注意,父标签内的所有子标签也可用于子项目。

希望这有助于...

关于java - 如何使用 Maven 部署多项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22942189/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com