Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3352192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:00:00+00:00 2026-05-18T02:00:00+00:00

i am new to maven. i have a Java EE Web project and a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:00:00+00:00Added an answer on May 18, 2026 at 2:00 am

    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:

    .
    ├── mymodule
    │   ├── pom.xml
    │   └── src
    │       ├── main
    │       │   ├── java
    │       │   └── resources
    │       └── test
    │           ├── java
    │           └── resources
    ├── mywebapp
    │   ├── pom.xml
    │   └── src
    │       └── main
    │           ├── resources
    │           └── webapp
    │               ├── index.jsp
    │               └── WEB-INF
    │                   └── web.xml
    └── pom.xml
    

    Where the parent pom.xml (at the root) would be like this:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.stackoverflow</groupId>
      <artifactId>Q4176120</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>pom</packaging>
      <name>Q4176120 - Parent POM</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        ...
      </dependencies>
      <modules>
        <module>mywebapp</module>
        <module>mymodule</module>
      </modules>
    </project>
    

    The mymodule/pom.xml would be a regular POM:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>Q4176120</artifactId>
        <groupId>com.stackoverflow</groupId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <!--groupId>com.stackoverflow</groupId--> <!-- inherited -->
      <artifactId>mymodule</artifactId>
      <packaging>jar</packaging>
      <name>Q4176120 - Module</name>
      <dependencies>
        ...
      </dependencies>
    </project>
    

    And mywebapp/pom.xml would declare a dependency on the mymodule artifact:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>Q4176120</artifactId>
        <groupId>com.stackoverflow</groupId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <!--groupId>com.stackoverflow</groupId--> <!-- inherited -->
      <artifactId>mywebapp</artifactId>
      <packaging>war</packaging>
      <name>Q4176120 - Maven Webapp</name>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>mymodule</artifactId>
          <version>${project.version}</version>
        </dependency>
      </dependencies>
      <build>
        <finalName>Q4176120</finalName>
      </build>
    </project>
    

    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):

    $ mvn install
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] Q4176120 Parent POM
    [INFO] Q4176120 Module
    [INFO] Q4176120 Maven Webapp
    [INFO]                                                                         
    ...
    

    Note that I also used inheritance in the above samples (mymodule and mywebapp inherit 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

    • Maven Documentation
      • Project Inheritance vs Project Aggregation
    • Maven Book
      • 3.6.2. Multi-module vs. Inheritance
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Maven. I have a multi-module maven 2 project that has the
I have a large Java Web Application project using Maven and I need to
I'm new to maven and have got a project with some dependencies. Now Maven
I have a maven project with 2 modules. There is a crawler module which
I have produced a new Maven Project from gae-archetype-gwt from within IntelliJ, and everything
I have a maven web project that imported into eclipse. I have another maven
I'm starting on a new project, and it seems to have some problems related
I have a multimodule maven setup for my project, made of 5 modules, which
I am new to maven and i have been creating simple web application with
hi i am building a dynamic web project in which the welcome page have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.