How would you manage multi-module Maven projects and their dependencies?

Multi-module Maven projects are managed through a parent POM that centralizes shared configuration, dependency versions, and plugin management, while each child module's POM inherits from it and adds only what's specific to that module. This keeps dependency versions consistent and avoids duplication across modules.

Key Points: • The parent POM uses packaging type "pom" and lists child modules under a <modules> section. • <dependencyManagement> in the parent declares versions centrally; child modules reference dependencies without repeating the version. • <pluginManagement> similarly centralizes plugin versions and default configuration for all modules. • Child modules declare <parent> to inherit group ID, version, and shared properties, reducing repeated boilerplate. • Inter-module dependencies (one module depending on another) are declared like any other dependency, using the module's artifactId and the shared version. • Running mvn install from the root builds modules in the correct dependency order automatically, based on the reactor.

Example: An e-commerce application split into order-service, inventory-service, and common-lib modules can share a single Spring Boot version defined once in the parent POM's dependencyManagement, so bumping the version in one place updates all modules consistently.

Code Example:

<!-- parent pom.xml -->
<packaging>pom</packaging>
<modules>
    <module>common-lib</module>
    <module>order-service</module>
    <module>inventory-service</module>
</modules>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>3.2.5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Interview Tip: A concise interview answer is:

"I use a parent POM with dependencyManagement and pluginManagement to centralize versions, and each module inherits from it and declares only what it actually needs. This keeps versions consistent across the reactor and means a single version bump in the parent propagates to every child module automatically."