Open In App

What is Maven?

Last Updated : 19 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Maven is a build automation tool developed using the Java programming language. It is primarily used for Java-based projects to manage the build process, including source code compilation, testing, packaging, and more. Maven utilizes the Project Object Model (POM), where the pom.xml file describes the project’s configuration and dependency management.

Features of Maven:

The Maven Build Automation tool provides a lot of features to make the development easy. Below we listed them

  • Dependency Management: Automatically downloads and manages external libraries.
  • Standard Project Structure: Follows a fixed folder layout for source, test, and other files.
  • Build Lifecycle: Defines standard build phases like compile, test, and deploy.
  • Plugins: Supports plugins for compiling, testing, packaging, and more.
  • POM File: Uses pom.xml to manage configuration and dependencies.
  • Central Repository: Fetches dependencies from a shared online repository.
  • Build Profiles: Supports different settings for dev, QA, and production.
  • Reporting: Can generate Javadoc, test reports, and project documentation.
  • IDE Support: Integrates with Eclipse, IntelliJ, NetBeans, etc.

Maven Project Structure

Maven Project Structure
Directory structure

Maven provides a standard Project folder structure you can observe this in the above image.

  • src/main/java: It contains the main Java source code.
  • src/main/resources: It contains non-Java resources used by the application.
  • src/main/webapp: It contains resources for web applications.
  • src/test/java: It contains test source code.
  • src/test/resources: It contains resources used for testing.
  • target: It contains compiled classes, packaged JARs/WARs, and other built artifacts.
  • pom.xml: The Project Object Model file that defines the project configuration, dependencies, and build settings.

Maven Build Life Cycle

In Maven Build life cycle there are different phases these phases are used for different purposes like test phase for complies tests, verify phases is used for tests and main source code and other.

  • Validate: This phase is responsible for validates if the project structure is correct or not.
  • Compile: It compiles the source code, converts the .java files to .class, and stores these classes in the target/classes folder.
  • Test: It runs unit tests for the maven project
  • Package: This phase is responsible for distribute complied code in the format of WAR, JAR and others.
  • Integration test: It runs the integration tests for the maven project
  • Verify: verify that the project is valid and meets the quality standards.
  • Install: This phase is responsible for install packaged code on the system.
  • Deploy: copies the packaged code to the remote repository for deployment then other developers can easily access this one.

Create a Simple Maven Project

Here, we create a sample maven project with required dependencies. Once project successfully created then observe the project folder structure. Then locate the pom.xml file that has required configuration for the maven project.

Dependencies

Java
<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

Project Folder Structure

Folder Structure
App structure

pom.xml:

XML
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.app</groupId>
    <artifactId>mavencommends</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>mavencommends</name>
    <description>Spring Reactive</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Advantage of Maven Build Tool

This tool provides a lot of advantages and most of the Software team use this tool for Automation Building.

  • Dependency Management: This Maven Tool can able to handle required Dependencies in the Software application. Maven simplifies dependency management by automatically downloading required libraries from repositories and managing their versions
  • Consistent Project Structure: It Provides a standard project structure to understand easily by the developers.
  • Build Life cycle: The Maven tool provides lot of Build Phase like verify, test and other build phases and Binds the phases with plugins.
  • Re usability: Maven promotes the reuse of project components through the use of dependencies and plugins, reducing duplication of effort.
  • Integration with IDEs: It supports IDEs like STS, Eclipse, IntelliJ IDEA, and NetBeans.
  • Automated Testing: The Maven provide testing commends for testing the test source code while go with test build phase in the Maven type project.

Introduction to Maven
Visit Course explore course icon
Article Tags :

Similar Reads