Maven is a build automation and dependency management tool primarily used for Java projects.
It helps you:
Spring Boot projects rely heavily on external libraries like:
Without Maven, you would manually:
Maven automates all of this.
my-project/
│
├── pom.xml
│
└── src/
├── main/
│ ├── java/
│ └── resources/
│
└── test/
└── java/
• Local Repository → .m2 folder in your system
• Central Repository → Default online repo
• Remote Repository → Company/private repo
Default Location:
C:\Users\YourName\.m2\repository
Stores downloaded dependencies locally.
https://repo.maven.apache.org/maven2
Official public repository maintained by Maven.
Used in companies (Nexus / Artifactory) to host private/internal dependencies.
Maven follows a predefined lifecycle for building projects.
validate
↓
compile
↓
test
↓
package
↓
verify
↓
install
↓
deploy
.m2 repository| Command | Purpose |
|---|---|
mvn clean |
Deletes target folder |
mvn compile |
Compiles source code |
mvn test |
Runs tests |
mvn package |
Creates JAR/WAR |
mvn install |
Installs in local repo |
mvn clean install |
Clean + full build |
<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>demo-app</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
</project><dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies><build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>Run application:
mvn spring-boot:run
Maven is:
Essential for Spring Boot project management and builds.