Junior — Middle
Can you explain the role and content of the pom.xml file in the Maven project management system?
sobes.tech AI
Answer from AI
The pom.xml file in Maven is the main configuration file of a project, where its settings and dependencies are described. "POM" stands for Project Object Model.
In pom.xml, the following are specified:
- Project information: groupId, artifactId, version.
- Dependencies: libraries and modules needed for building and running the project.
- Plugins: tools for building, testing, packaging, and other tasks.
- Build settings: compilation parameters, profiles for different environments.
An example of a simple pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Thus, pom.xml manages the entire project lifecycle in Maven — from downloading dependencies to building and testing.