多webapp Maven 2项目——如何构建单个webapp?

发布于 2024-09-28 02:59:20 字数 466 浏览 0 评论 0原文

我有以下源布局:

.
├── pom.xml
├── modules (has pom)
│   ├── module1 (has pom) 
│   └── module2 (has pom)
│   └── moduleN (has pom)
└── webapp1 (has pom)
└── webapp2 (has pom)

webapp1 和 webapp2 依赖于所有模块(模块是 DAO、服务等)。 目前,我从根目录构建所有内容,mvn package 为我提供了两个 WAR 文件。

如何仅构建 webapp1 或 webapp2?

如果我cd进入webapp1并运行mvn package,它会说它无法下载moduleX.jar(这是一个干净的存储库)。当然,Maven 应该能够推断出这些模块需要首先作为依赖项构建?

I have the following source layout:

.
├── pom.xml
├── modules (has pom)
│   ├── module1 (has pom) 
│   └── module2 (has pom)
│   └── moduleN (has pom)
└── webapp1 (has pom)
└── webapp2 (has pom)

webapp1 and webapp2 depends on all of the modules (the modules being DAO, services, etc).
At the moment, I build everything from the root and mvn package gives me two WAR files.

How do I build only webapp1 or webapp2?

If I cd into webapp1 and run mvn package it says it can't download moduleX.jar (this is with a clean repository). Surely Maven should be able to deduce that those modules need to be built first as dependencies?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杯敬自由 2024-10-05 02:59:20

如何仅构建 webapp1 或 webapp2?

使用“高级反应器选项”。从根开始:

mvn install -pl webapp1 -am

这告诉 maven 安装 webapp1 以及 webapp1 所依赖的项目(以正确的顺序)。

帮助(mvn -h)记录了这些命令,如下所示:

-pl, --projects
        Build specified reactor projects instead of all projects
-am, --also-make
        If project list is specified, also build projects required by the list

请注意,您需要调用install,依赖项始终通过本地存储库解析(因此您需要安装它们)。我错了,调用package确实有效(我不知道如何/为什么,但它确实有效)。

How do I build only webapp1 or webapp2?

Use "advanced reactor options". From the root:

mvn install -pl webapp1 -am

This tells maven to install webapp1 and the projects on which webapp1 depends (in the right order).

The help (mvn -h) documents these commands like this:

-pl, --projects
        Build specified reactor projects instead of all projects
-am, --also-make
        If project list is specified, also build projects required by the list

Note that you need to invoke install, dependencies are always resolved through the local repository (so you need to install them). I was wrong, calling package does work (I don't know how/why, but it does).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文