Maven
34 questions in 12 subtopics.
Build lifecycle and phases
In Maven, what is the difference between a lifecycle, a phase and a goal? What actually runs when you type 'mvn package' on a jar project?A team's integration tests run with Surefire during 'mvn test' and leave a Docker database running whenever a test fails. How would you restructure the build so the environment is always torn down?A developer says 'mvn install' is required before every build of your multi-module project because modules cannot see each other's changes. What is going on and how would you fix the workflow?Dependency management and scopes
Explain Maven dependency scopes compile, provided, runtime, test, system and import. Which of them are transitive?What is the difference between declaring a dependency under <dependencies> and under <dependencyManagement> in a parent POM? Show what a child module must write to use a managed version.Your organisation has 40 Maven services that each declare their own library versions. How would you introduce central dependency management without forcing every team into one parent POM?BOMs
What is a BOM in Maven, and why do Spring Boot projects that do not use spring-boot-starter-parent import spring-boot-dependencies?A project imports both spring-boot-dependencies and a cloud vendor SDK BOM. After an upgrade, Netty classes fail withNoSuchMethodError at runtime. How do imported BOMs interact, and how do you find and fix the conflict?You own the internal platform BOM used by 200 Java services. How do you decide what goes into it, how often it is released, and how teams consume upgrades safely?Plugins
A colleague configures the maven-compiler-plugin with source and target 17 but the code uses Java 21 APIs and still compiles on a JDK 21 machine, then fails on Java 17 at runtime. Why, and what is the correct setting?ExplainpluginManagement versus plugins in Maven, and why builds that rely on default plugin versions are a problem.Several teams copy the same 150 lines of plugin configuration (compiler, Surefire, JaCoCo, Spotless, Enforcer) into every service. Propose a way to share and evolve it.A Maven plugin that every one of your 300 builds depends on is abandoned upstream and fails on the next JDK release. What options do you weigh, and what policy would you set so this hurts less next time?Multi-module builds
In a Maven multi-module project, what is the reactor and how does it decide build order? What do the -pl, -am, -amd and -rf options do?A 60-module Maven build takes 25 minutes in CI even for one-line changes. What would you measure and change?How would you decide between one large multi-module repository and separate repositories per service for 30 Spring Boot services owned by six teams?Your company has 15 years of Maven builds: some services on a corporate parent from 2012, some on spring-boot-starter-parent, some with no parent. How would you converge on one build convention without a big-bang migration, and how do you judge whether it is worth the cost?Profiles
A Maven profile markedactiveByDefault stops applying as soon as a developer runs 'mvn -Pfast verify'. Why does this happen, and what are better ways to activate profiles?A service uses Maven profiles dev, qa and prod to package different configuration files into the jar. What are the drawbacks and what would you recommend instead?Dependency resolution conflicts
How does Maven choose a version when two paths in the dependency graph bring different versions of the same artifact?After adding a reporting library, a Spring Boot service fails at startup withjava.lang.NoSuchMethodError in com.google.common.collect. Walk through how you would diagnose and fix it in Maven.Looking back over the last 15 years of Java builds, why has dependency conflict management moved from individual projects to organisation-wide policy, and what policy would you set today?Repositories and settings.xml
Where does Maven look for dependencies, in what order, and what goes insettings.xml versus pom.xml? How do you route all downloads through a company Nexus or Artifactory?CI builds fail intermittently with 'Could not transfer artifact ... from/to central: status code 429' and some builds pick up a SNAPSHOT another team deployed an hour ago. What changes do you make?Design the artifact repository setup for 500 developers and 800 Maven builds, including internal libraries, third-party proxies, and protection against dependency confusion and malicious packages.Project setup and archetypes
How do you create a new Maven project from scratch, and what is an archetype? What would you use instead of an archetype to start a Spring Boot service?Your company creates about 40 new services a year and each one starts from a copy of an older service, carrying outdated plugins and configuration. How would you provide a better starting point?Compiler and Java version settings
A project builds with JDK 21 usingmaven.compiler.source=17 and target=17 and deploys to Java 17. In production it fails with NoSuchMethodError on a JDK method. Why, and what is the correct setting?You are moving 30 services from Java 17 to Java 25. What Maven build settings and plugin versions must change, and how do you roll it out?POM structure and inheritance
Explain the difference between a parent POM (inheritance) and an aggregator POM (modules). What is inherited from a parent, and what is the super POM?A service uses spring-boot-starter-parent and also needs the company's corporate parent POM, but Maven allows only one parent. What are your options and their trade-offs?Your company has a corporate parent POM that 1,200 builds inherit, and every change to it is risky and slow. How do you organise ownership, release and evolution of build standards for the next decade?Maven 4 changes
What are the main changes in Maven 4 compared with Maven 3, and what should you check before moving builds? Mention the build POM versus consumer POM.You are responsible for the build platform for 600 Maven projects. Make the plan for adopting Maven 4: when, in what order, and with which safeguards.No question matches these choices.