POM

This lesson explains the purpose and structure of the POM file.

A Maven project is described by a POM file. POM stands for Project Object Model and is a declarative description of a project. It defines the unique Maven coordinates of the project, the dependencies of the project, required plugins, any parameters required for the goals Maven executes in the context of the project, etc. It is an XML file that contains information about the project and configuration details used by Maven to build the project. Maven, when invoked, looks for the POM file and works from it. In the absence of a POM file, Maven will throw an error. When executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal. Some of the configurations that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists, and so on can also be specified.

Here’s the minimal version of a POM file.

<?xml version="1.0" encoding="UTF-8"?>

<project>

    <modelVersion>4.0.0</modelVersion>
    <groupId>io.datajek</groupId>
    <artifactId>empty-project</artifactId>
    <version>1</version>

</project>

The file contains minimal project description. It doesn’t define any dependencies or plugins. If you run mvn install in the directory containing the above POM file, you’ll see a successful build. Let’s try that in the terminal below:

Get hands-on with 1400+ tech skills courses.