Question

What is the difference between maven multimodule project(pom packaging) and ear packaging. As i know Ear is used to package a group of related Module (EJB, JPA, JSF). After reading maven documentation i found that multimodule project is used for the same thing.

Are they the same? Can i use multimodule project instead of EAR? can mutlimodule project be deployed to application servers?

Was it helpful?

Solution 2

multi module is just a way of organising your project into modules/components.the packaging need not be ear always.it can be for instance a war project that has all its server side content as a jar file in one of its module.

in short,multi module organisation can be opted for a ear project but the converse that mutli module is always a ear project is not true.

OTHER TIPS

A multi-module project (packaging of pom) is a way of defining a parent pom that has child modules. This is convenient for many reasons. For one, you can just build the parent pom with mvn compile and it will build all of its modules, too. Without the parent pom, you'd have to go into each pom and manually type mvn compile otherwise.

Not only that, but using modules gives you other really important features. See the answer to this question. To summarize, imagine you have a continuous integration server that just installed in the middle of you building locally. By using module, you ensure that you compile against your local code instead of the continuous integration server's code. This will prevent a lot of heisenbugs(sp?).


Now the packaging of ear is not directly related to this first multi-module concept. That packaging just determines the binary output. It will output an ear file. In the maven-ear-plugin plugin, you can include other modules like wars/jars/ejbs, but it won't do any of the things I've described in the first paragraph. For example, typing mvn compile in the directory of the ear's pom.xml file will not compile the war file it depends on.

Also, you don't have to include other maven modules in your ear. Another completely unrelated project may install an ejb and you can use that ejb in your ear just as a dependency.

The two are not the same. A multi-module project just builds all sub modules, it does not produce an artifact.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top