A complex Maven build and its key plugins, optimising multi-module builds, how dependency resolution and mediation work (and a real conflict), pom.xml's role, lifecycles vs phases, managing multi-module projects, build-speed techniques, starters, migrating a legacy project, and handling version conflicts.
Published September 25, 2026
Level II Maven questions assume you've fought a real build: a dependency conflict, a slow CI pipeline, a multi-module refactor. Use precise mechanics (nearest wins, BOM import, reactor, -pl -am), and a short story wherever the question asks "describe a time".
Short answer (a model build for a Spring Boot service):
maven-compiler-plugin: release 21, -parameters, annotation processors (MapStruct, Lombok) in a defined order.maven-surefire-plugin runs the unit tests, and maven-failsafe-plugin runs *IT integration tests in integration-test/verify, using Testcontainers.jacoco-maven-plugin: coverage reports, plus a coverage gate in verify.maven-enforcer-plugin: requires the Maven and Java versions, and uses dependencyConvergence and banDuplicateClasses to catch conflicts early.spring-boot-maven-plugin: repackage into an executable JAR, build-info, and build-image for OCI images.openapi-generator-maven-plugin: generates API interfaces from the spec.flyway-maven-plugin, or migrations run at application startup.Key points to cover:
pluginManagement), and keep CI and local builds identical with the Maven Wrapper.Short answer:
-T 1C.-pl changed-module -am (plus the modules it depends on), or -amd (plus the modules depending on it).~/.m2 in CI.Short answer: Maven builds the dependency graph (direct plus transitive dependencies), then mediates versions when the same artifact appears more than once:
<dependencyManagement> (and imported BOMs) override both, pinning the versions for the whole build.Scopes also affect what's visible where.
The story (model): "After adding an SDK, the app threw NoSuchMethodError in Jackson at startup. mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.core showed the SDK pulling an older jackson-databind that was 'nearer' than Spring Boot's. I removed the override, let the Jackson BOM managed by Spring Boot pin the version, excluded the SDK's copy, and added an Enforcer dependencyConvergence rule so a drifting version would fail the build."
pom.xml?Short answer: It's the project's build model:
groupId:artifactId:version) and packaging;Maven combines it with its parents (up to the super POM) into the effective POM, and executes it (mvn help:effective-pom shows the result).
Short answer: There are three lifecycles:
clean: pre-clean, clean, post-clean.default: the build itself: validate, compile, test, package, integration-test, verify, install, deploy, and more.site: documentation.Invoking a phase runs all the earlier phases of its lifecycle. Plugin goals bound to each phase (depending on the packaging, plus your own bindings) do the actual work.
Learn it in depth → Maven Interview Questions (fresher)
Short answer:
<packaging>pom</packaging>) lists the <modules>, and centralises:
dependencyManagement: versions only, with no forced inclusion;pluginManagement;${project.version}.<scope>import</scope>.Key points to cover:
api → domain → persistence → app), so the reactor can build it in order and in parallel.${revision} with the flatten plugin, so a single version is set in one place.Short answer: Measure first (see "build time increasing", in the next lesson), then:
-T 1C parallel builds.-o offline mode, when the cache is warm.-pl/-am).forkCount), no Spring context in unit tests, reused Testcontainers.-Dcheckstyle.skip), but never in CI.Short answer: A Spring Boot starter is a single dependency that brings a curated, compatible set of libraries for one capability. For example, spring-boot-starter-data-jpa brings Hibernate, Spring Data JPA, HikariCP and the transaction support. Versions come from Boot's BOM, and the matching auto-configuration activates. You get fewer declarations, fewer version conflicts, and consistent setups across services.
Key points to cover:
acme-observability-starter) to standardise logging, tracing and security across teams.Short answer:
lib/*.jar files, code generation, packaging, deployment steps.install:install-file on each laptop).src/main/java, src/test/java, resources), or configure custom paths at first to reduce churn.Short answer:
mvn dependency:tree -Dverbose, and the Enforcer's dependencyConvergence rule.<dependencyManagement>, preferably through the library's BOM (the Jackson, Netty or AWS SDK BOMs), so related modules stay aligned.<exclusions>.Common trap: believing the "newest version wins" automatically. Maven picks the nearest version, which may be the older one, and the result is NoSuchMethodError at runtime.
Q: dependencyManagement vs dependencies?
A: dependencyManagement only declares versions and scopes. It doesn't add anything to the classpath. dependencies actually adds libraries. Child modules inherit the managed versions when they declare the dependency.
Q: What's the difference between Surefire and Failsafe?
A: Surefire runs unit tests in the test phase, and fails the build immediately. Failsafe runs integration tests in integration-test, and fails in verify, so post-integration-test teardown (such as stopping containers) still runs.
Q: What's a BOM?
A: A "bill of materials": a POM that exists only to manage versions for a family of artifacts. You import it into <dependencyManagement> with type pom and scope import.
Q: What does mvn verify do that mvn package doesn't?
A: It also runs the integration tests and verification checks (coverage gates, Enforcer rules bound to verify). It's the right default command for CI.