Maven Central Repository

Last Updated : 23 Mar, 2026

The Maven Central Repository is the default remote repository used by Maven to download project dependencies. It provides a centralized platform for accessing open-source libraries and artifacts. Developers can easily fetch and manage dependencies required for building Java applications.

  • Automatically downloads dependencies for projects
  • Supports version management and compatibility

Workflow of Maven Central Repository

Here is a diagram depicting how Maven Central Repository fits into the workflow of a Maven Project.

Workflow of Maven Central Repository

Explaination of Workflow:

  • Define Dependencies: Add required dependencies in pom.xml
  • Check Local Repository: Maven first looks for dependencies locally
  • Search Central Repository: If not found, Maven queries the central repository
  • Download Dependencies: Required artifacts are downloaded
  • Store Locally: Saved in local repository for future use
  • Build Project: Maven uses dependencies to compile and package the project

Step-by-Step Example of Maven Central Repository

Step 1: Create a Maven Project

Use Maven command or IDE to create a project.

mvn archetype:generate -DgroupId=com.app -DartifactId=mavencommends -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Step 2: Add Dependencies in pom.xml

The pom.xml which includes required project dependencies and project configuration.

XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://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>
    <profiles>
        <profile>
            <id>skip-tests</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>
    </profiles>
    <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>

Step 3: Run Maven Build Command

Execute this command.

mvn clean install

Step 4: Dependency Resolution

  • Maven checks local repository (.m2 folder)
  • If not found -> downloads from Maven Central Repository
Maven Dependency Resolution Progress

Step 5: Store in Local Repository

Downloaded dependencies are saved in:

~/.m2/repository

Step 6: Build and Run Project

  • Maven compiles and packages the project into a JAR/WAR
  • Application is ready to run
Comment
Article Tags:

Explore