Maven 多模块和 EAR 可以很好地协同工作吗?

发布于 2024-09-06 15:00:45 字数 380 浏览 2 评论 0原文

今天,我一直在研究 Maven 多模块和 EAR 项目,它们看起来非常相似,因为两者似乎都定义了其他项目集合的集合 - 几乎看起来 EAR 项目应该只是多模块项目。

我是不是误会了什么?或者这些类型的项目可以一起工作吗?


以下是帕斯卡的回答: 更新以澄清问题,如果不容易理解,希望这会有所帮助;抱歉,它的措辞可能不太好,耳朵的东西对我来说有点新鲜……

所以假设我有两个项目,一个产生一场战争,另一个产生一个实用程序罐子。战争取决于jar,我需要将它们打包到耳朵中进行部署。我应该使用 pom 打包类型的项目吗?我想我必须在某个地方使用带有 Ear 包装类型的项目来生成最终的工件,所以我最好只使用带有 Ear 包装的项目,还是同时带有 pom 和 Ear 的项目?如果两者都有,怎么办?

Today, I've been looking at Maven Multi-Module and EAR projects and they seem quite similar in that both seem to define an assembly of a collection of other projects - it almost seems like an EAR project should just be an alternate packaging for a multi-module project.

Have I misunderstood something? Or do these types of project work together?


Following Pascal's answer:
Updated to clarify the question, hopefully that will help if it's not easy to understand; sorry it's maybe not phrased very well, the ear stuff is kinda new to me...

So say I have two projects, one producing a war and the other a utility jar. The war depends on the jar and I need to package them up into an ear for deployment. Should I use a project with a pom packaging type? I guess I have to use a project with an ear packaging type somewhere to produce the final artifact, so am I best using just a project with ear packaging, or projects with both pom and ear? If both, how?

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

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

发布评论

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

评论(2

天赋异禀 2024-09-13 15:00:45

EAR 项目作为更大的聚合项目的一部分工作得很好。在这些情况下,当您不希望 EAR 成为一个单独的项目时;您始终可以通过程序集创建文件。

这种方法在某些情况下是有意义的。通常,您必须创建 EAR 的多个版本,或者您想要创建和部署大型 EAR 文件,但创建后无需保留工件。

我已经使用这种方法来处理要求所有可部署文件都是 EAR 文件的公司标准,即使应用程序是单个 WAR 文件也是如此。程序集可以使用其单个 WAR 文件和部署描述符创建 EAR。

EAR projects work just fine as part of a larger aggregated project. In those cases when you do not want to have the EAR be a separate project; you could always create the file via an assembly.

This approach makes sense in some cases. Usually where you have to create multiple versions of the EAR or when you would like to create the deploy a large EAR file but have no need to keep the artifact once created.

I've used this approach to deal with a corporate standard that requires all deployable to be EAR files, even when the app is a single WAR file. An assembly can create the EAR with its single WAR file and deployment descriptors.

浅忆流年 2024-09-13 15:00:45

我是不是误会了什么?或者这些类型的项目可以一起工作吗?

我不确定我是否理解这个问题,但我很想回答它们可以一起工作:

  • 聚合模块允许聚合模块,并且它们必须具有 pom 包装(并且只有 pom 模块可以有嵌套项目)。
  • EAR 模块只是一个带有 ear 包装的模块(并且具有特定的 绑定)并且可以是多模块项目的一部分。

两者都有不同的目的。但他们一起工作。

Have I misunderstood something? Or do these types of project work together?

I'm not sure I understood the question but I'm tempted to answer that they work together:

  • Aggregating modules allow to, well, aggregate modules and they must have a pom packaging (and only pom modules can have nested projects).
  • An EAR module is just a module with an ear packaging (and has specific bindings) and can be part of a multi-module project.

Both have different purposes. But they work together.

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