This guide distills a large legacy Maven Q&A into interview-ready explanations for DevOps and Java engineers. You will learn how to answer common Maven questions clearly, with practical examples for configuration scope, lifecycle execution, repository strategy, plugin setup, and debugging.
Originally published on 2010-04-16; fully revised and updated.

Original compilation was contributed by Rajesh Kumar, with references to scmGalaxy.com and Maven community documentation. This revision keeps the useful technical patterns and removes repetition.
What Maven interviewers usually test
Most Maven interviews test whether you understand standard lifecycle behavior, configuration boundaries, and dependency/repository operations in real projects.
- Difference between
pom.xmlandsettings.xml - How plugin goals bind to lifecycle phases
- How to troubleshoot dependency resolution and test execution
- How multi-module and aggregator builds work
- How to configure packaging details (manifest, output directory, assembly)
| Interview topic | Strong answer should include | Typical follow-up question |
|---|---|---|
| Configuration scope | Project config in POM; user/machine config in settings | When would you use mirrors instead of project repositories? |
| Lifecycle | Default phases plus plugin goals bound per phase | Where would you attach code generation? |
| Dependencies | Transitive resolution, local cache, debug commands | How do you find the source of a conflict? |
| Packaging | Compiler/jar/assembly plugin customization | How do you create multiple distributables? |
Configuration scope and precedence: pom.xml, settings.xml, and CLI
A reliable interview answer is: use pom.xml for project behavior and settings.xml for user/environment behavior (credentials, mirrors, local policy). CLI properties are typically the highest-priority temporary overrides.
| Location | Scope | Good use | Avoid |
|---|---|---|---|
| pom.xml | Shared project | Dependencies, plugins, build/reporting config | Personal credentials or machine-specific paths |
| settings.xml | User or CI agent | Mirrors, auth, proxies, local repository policy | Project logic needed by all developers |
| -Dkey=value | Per run | Temporary overrides and experiments | Hidden permanent behavior |
<!-- project-level repository declaration -->
<project>
<repositories>
<repository>
<id>company-proxy</id>
<url>https://repo.example.com/maven2</url>
</repository>
</repositories>
</project>
<!-- user-level mirror declaration -->
<settings>
<mirrors>
<mirror>
<id>local-mirror</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.example.com/maven2</url>
</mirror>
</mirrors>
</settings>Code language: HTML, XML (xml)
The original FAQ states precedence as parent POM, project POM, settings, then CLI (last one wins). In practice, interviewers usually care that you understand CLI overrides are strongest for that run.
How Maven lifecycle execution works
When asked about Maven architecture, describe the sequence from model loading through dependency resolution and phase-bound plugin execution.
flowchart TD
A[Run mvn clean verify] --> B[Load parent and project POM]
B --> C[Apply settings and active profiles]
C --> D[Resolve dependencies from repositories]
D --> E[Execute lifecycle phases]
E --> F[Run plugin goals bound to each phase]
F --> G[Produce artifacts and reports]
mvn clean verify
Common technical questions with practical examples
How can I use the current date in a build?
The original answer uses the buildnumber plugin to generate a timestamp during validate. This is a legacy example from the original post.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-buildnumber-plugin</artifactId>
<version>0.9.4</version>
<configuration>
<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
<items>
<item>timestamp</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>Code language: HTML, XML (xml)
How do I configure array and map types in Mojo/plugin configuration?
<configuration>
<tags>
<tag>value1</tag>
<tag>value2</tag>
</tags>
<myMap>
<yourkey>yourvalue</yourkey>
</myMap>
</configuration>Code language: HTML, XML (xml)
What causes duplicate plugin execution errors?
If you execute a plugin multiple times with the same execution ID (or missing IDs), Maven reports a duplicate execution problem. Give each execution a unique ID.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>bin-dist</id>
<phase>install</phase>
<goals><goal>assembly</goal></goals>
<configuration>
<descriptor>src/main/descriptors/bin.xml</descriptor>
<finalName>${project.build.finalName}-bin</finalName>
</configuration>
</execution>
<execution>
<id>src-dist</id>
<phase>install</phase>
<goals><goal>assembly</goal></goals>
<configuration>
<descriptor>src/main/descriptors/src.xml</descriptor>
<finalName>${project.build.finalName}-src</finalName>
</configuration>
</execution>
</executions>
</plugin>Code language: HTML, XML (xml)
How do I change jar output location and add a Main-Class?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/custom</outputDirectory>
<archive>
<manifest>
<mainClass>com.mycompany.app.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>Code language: HTML, XML (xml)
How do I install a third-party jar into the local repository?
mvn install:install-file -Dfile=/path/to/file.jar -DgroupId=com.example -DartifactId=custom-lib -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=trueCode language: JavaScript (javascript)
Why are tests compiled but not executed?
The original FAQ notes accidental test filtering via a test property. Check both POM and settings for unintended values.
<properties>
<test>SomeSpecificTest</test>
</properties>Code language: HTML, XML (xml)
mvn test -Dtest=SomeSpecificTest
Repository models and interview-ready trade-offs
Be ready to explain local cache behavior, private organizational proxies, and external remotes. The original article uses older terminology like ibiblio; the core architecture idea still applies.
| Repository type | Purpose | Interview talking point |
|---|---|---|
| Local repository | Developer/agent cache of resolved artifacts | Speeds repeated builds and supports offline work |
| Private remote repository | Organization-controlled proxy/hosted artifacts | Policy control, access control, and reliability |
| Public remote repository | External source for open artifacts | Usually accessed via internal mirror/proxy in enterprises |
- Prefer repository implementations with admin tooling, backup strategy, and access control.
- Use internal repositories to reduce internet dependency and improve repeatability.
- Keep internal artifacts separated from proxied external artifacts.
Ant vs Maven: explain the difference without oversimplifying
| Aspect | Ant | Maven |
|---|---|---|
| Model | Task-oriented scripting | Lifecycle and convention-oriented |
| Flexibility | Very high; manual wiring | High via plugins within lifecycle conventions |
| Standardization | Team-defined | Strong defaults and common structure |
| Dependency management | Manual unless extended | Built-in transitive dependency model |
You can still run Ant tasks from Maven when needed (for small project-specific tasks) using the AntRun plugin and multiple executions bound to different phases.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>one</id>
<phase>generate-sources</phase>
<goals><goal>run</goal></goals>
</execution>
<execution>
<id>two</id>
<phase>package</phase>
<goals><goal>run</goal></goals>
</execution>
</executions>
</plugin>Code language: HTML, XML (xml)
Useful troubleshooting commands and references
mvn -X
mvn -e
mvn help:effective-pom
mvn dependency:tree
mvn --helpCode language: CSS (css)
Useful documentation links from the original material: Antrun classpath references, Assembly Plugin documentation, Using external Ant tasks, and historical reference at javabeat.net.
Common pitfalls in interview answers
- Mixing user-specific settings (mirrors, credentials) into
pom.xml. - Forgetting unique execution IDs when the same plugin runs multiple times.
- Assuming compiled tests will always run; hidden
testfilters can skip suites. - Using old Maven 2-era snippets without validating them against your current stack.
- Giving only theory; always include at least one command or plugin snippet in your answer.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals