The POM (Project Object Model) is the XML file, pom.xml, that Maven uses as the single source of truth for a project's configuration. It declares the project's coordinates, dependencies, plugins, build settings, and other metadata that Maven reads to execute lifecycle phases.
Key Points: • Every Maven project has exactly one pom.xml at its root, and multi-module projects have a parent POM aggregating child modules. • It defines the project's coordinates: groupId, artifactId, and version (GAV), which uniquely identify the artifact. • Dependencies are declared inside <dependencies>, and Maven resolves them (and their transitive dependencies) from configured repositories. • Plugins and their configuration, declared under <build><plugins>, control how lifecycle phases behave, such as compiling, packaging, and testing. • A parent POM can be inherited via <parent> to share common configuration across modules.
Example: A simple Spring Boot service's pom.xml declares spring-boot-starter-web as a dependency and inherits from spring-boot-starter-parent, which supplies sensible default plugin versions and configuration.
Code Example:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo-app</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>Interview Tip: A concise interview answer is:
"The POM is Maven's XML configuration file, pom.xml, that describes a project's identity, dependencies, plugins, and build configuration. Maven reads it to know what to build, what libraries to pull in, and how to execute each lifecycle phase."