The pom.xml (Project Object Model) file is Maven's central configuration file, describing a project's identity, dependencies, plugins, and build settings in declarative XML. It's the equivalent of Gradle's build.gradle and is required for every Maven project.
Key Points: • Defines core project identity: groupId, artifactId, version, and packaging type (jar, war, pom, etc.). • Declares all project dependencies, which Maven resolves automatically from configured repositories along with their transitive dependencies. • Configures build plugins and their bindings to lifecycle phases, controlling compilation, testing, and packaging behavior. • Can define profiles for environment-specific configuration and a parent POM for shared settings in multi-module projects. • Because it's declarative, two engineers reading the same pom.xml can predict exactly how the project builds without needing to trace custom script logic.
Example: A basic Spring Boot pom.xml declares the spring-boot-starter-parent as its parent, lists spring-boot-starter-web as a dependency, and applies the spring-boot-maven-plugin — three concise elements that fully describe a runnable web application build.
Code Example:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo-app</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>Interview Tip: A concise interview answer is:
"pom.xml is Maven's central configuration file — it defines the project's identity, its dependencies, and the plugins that control how it's built, tested, and packaged. Because it's fully declarative XML, it makes the build predictable and easy for anyone on the team to read without tracing custom script logic."