It simplifies compiling, packaging, testing, and deploying applications by handling all build steps and external libraries automatically through configuration rather than manual scripting.
It’s built around the idea of a Project Object Model (POM) — a single XML file (pom.xml) that describes:
The project structure and metadata (name, version, etc.)
Dependencies (external libraries the project needs)
Plugins (tools for compiling, packaging, testing, etc.)
Build configurations and lifecycle instructions
Every Maven project has a pom.xml.
Example:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo-app</artifactId>
<version>1.0.0</version>
<dependencies>
<!-- Example dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
Maven has predefined build lifecycles such as:
clean → remove old build artifacts
compile → compile source code
test → run unit tests
package → build JAR/WAR files
install → add the package to your local repository
deploy → publish to a remote repository
Run these via commands like:
mvn clean package
mvn spring-boot:run
Maven automatically:
Downloads Java libraries (dependencies) from central repositories.
Handles classpath setup.
Runs compilation, testing, and packaging with standard conventions (like putting Java code in src/main/java).
Include Spring dependencies easily:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.0</version>
</dependency>
Build and package the app into a deployable WAR file.
Manage multiple Spring modules (like spring-webmvc, spring-jdbc, etc.) automatically, resolving version conflicts.
Spring Boot builds on top of Spring + Maven, and simplifies configuration further.
Use a starter parent POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
</parent>
This gives:
Managed versions for dependencies (no need to specify versions manually).
Common plugin configurations for building and running Boot apps.
Add starters (pre-bundled dependency sets):
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
Run directly using Maven:
mvn spring-boot:run
which compiles and launches the embedded server (like Tomcat) automatically.