Building with Apache Maven


Maven is an Open Source project made by Apache and today we will build with it.
It is a very powerful tool in terms of code compilation and development team collaboration.
The heart of a Maven project is the pom.xml configuration file.

One of the most important features of Maven is the automatic download of the libraries needed by a Java project, solving the dependencies.
“Dependency” means a class that is instantiated by a “new” keyword. So in Maven dependencies mean libraries “jars” that are necessary for the Java project to request services.
The POM (Project Object Model) describes the structure of a J2EE project, it is connected to a Remote Repository where in the project start-up phase it downloads all the dependencies listed in this file.
A local repository is created on this directory in the Windows environment:


So when the pom.xml requires a new dependency it is deposited in that folder. This path can also be configured and/or shared online with your development team.
Some key elements that can be used in the Maven configuration on a J2EE project are: plugins and goals.
The goals are functions that can be executed at the project level which, as the term itself suggests, identifies the objectives.

The most common goal is to build our project.
You’ll find it in the target/ directory of the project:

mvn package

An example pom.xml follows with comments:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""

  <!-- our project base informations -->

  <!-- our parent pom configuration (in this case we're using Spring Boot) -->

  <!-- jar to import in our project with utils and libraries -->
    <!-- other dependencies follow... -->

  <!-- our project start class -->

  <!-- you can add properties like settings for jdk version or maven version -->

  <!-- configure your base class when building -->

  <!-- from which repository we can import dependencies -->
    <repository> <!-- For Device -->
      <name>Spring Milestones</name>

To install Maven you can follow the ufficial link:

Be the first one to like this.
Please wait...

Leave a Reply

Thanks for choosing to leave a comment.
Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published.
Please do NOT use keywords in the name field. Let's have a personal and meaningful conversation.