Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

java - Maven: Combining multiple module jars into one war file?

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

in babybird's pom.xml I have following

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

when I run mvn clean install, I see

[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] ------------------------------------------------------------------------

and each one of these modules generate a jar file.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 module should depend on all others:

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

and have war packaging:

<packaging>war</packaging>

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...