Maven:将多个模块jar合并到一个war文件中? [英] Maven: Combining multiple module jars into one war file?

查看:73
本文介绍了Maven:将多个模块jar合并到一个war文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目babybird,其中包含3个组件persistencebusinessservice

I have a project babybird which has 3 components persistence, business and service

babybirdpom.xml中,我关注了

   <modules>
        <module>persistence</module>
        <module>business</module>
        <module>service</module>
    </modules>

当我运行mvn clean install时,我看到

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] babybird  ......................................... SUCCESS [2.801s]
[INFO] persistence ....................................... SUCCESS [3.321s]
[INFO] business .......................................... SUCCESS [0.832s]
[INFO] service ........................................... SUCCESS [0.694s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.168s
[INFO] Finished at: Tue Jan 22 12:09:48 PST 2013
[INFO] Final Memory: 18M/50M
[INFO] ------------------------------------------------------------------------

每个模块都会生成一个jar文件.

and each one of these modules generate a jar file.

问题:如何将它们组合为一个babybird.war?
我是Maven的新手,不知道要寻找什么来完成此任务,请提供指示信息

Question: How can I combine them into one babybird.war?
I am new to Maven and do not know what to look for to accomplish this task, please provide the pointers

推荐答案

那很简单.创建另一个名为web或类似名称的模块:

That's fairly simple. Create another module named web or similar:

<modules>
    <module>persistence</module>
    <module>business</module>
    <module>service</module>
    <module>web</module>
</modules>

web模块应依赖于所有其他模块:

web module should depend on all others:

<dependencies>
    <dependency>
        <groupId>...</groupId>
        <artifactId>persistence</artifactId>
    </dependency>
    ...
</dependencies>

并具有war包装:

<packaging>war</packaging>

/src/main/webapp/WEB-INF中,您还将需要web.xml.就是这样.

You'll also need web.xml in /src/main/webapp/WEB-INF. That's it.

这篇关于Maven:将多个模块jar合并到一个war文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆