Maven:将多个模块jar合并到一个war文件中? [英] Maven: Combining multiple module jars into one war file?
问题描述
我有一个项目babybird
,其中包含3个组件persistence
,business
和service
I have a project babybird
which has 3 components persistence
, business
and service
在babybird
的pom.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屋!