i am new to maven.
i have a Java EE Web project and a model project,web project is depend on model because module has some standard classed which need to be jar in web.
web needs model jar file.
how can i write the 2 projects which one is depend on another ?
give me a sample coding on both project pom.
A typical maven multi-modules project structure would involve 3 modules here: an aggregating parent module (allowing to start a multi-module build on all modules), the model module and the web module. Something like this:
Where the parent
pom.xml(at the root) would be like this:The
mymodule/pom.xmlwould be a regular POM:And
mywebapp/pom.xmlwould declare a dependency on the mymodule artifact:With this structure, you can start a multi-modules build from the parent directory i.e. run a goal on all modules (and maven will calculate the right build order):
Note that I also used inheritance in the above samples (
mymoduleandmywebappinherit from a parent that is declared in the<parent>element) so that I can group common parts in a parent POM and avoid repeating things. This is not mandatory, you can use aggregation without inheritance but this is very handy and aggregation and inheritance often go together in practice.Resources