Monday, February 16, 2026
HomeLanguagesJavaHow Maven Searches for Dependencies for a Project?

How Maven Searches for Dependencies for a Project?

Maven is a build automation tool that is used for java projects for various activities like dependency management, building the project, documentation, unit testing, etc provided by Apache. One of the key activities of Maven is Dependency management because it’s one of the most difficult jobs for developers to manage hundreds of dependencies and artifacts for multiple projects. Maven manages and gets these dependencies from repositories. There are mainly three types of repositories.

Repositories Available in Maven

1. Local Repository

This repository is located on your local workstation, and it’s available on the C:\Users\<user_name>\.m2\repository for windows, the path may vary for other operating systems like MAC, Linux, etc. When we build a Maven project, all the required dependency jar files into this folder, and further reuse the same jars for other projects which requires the same dependencies. 

Settings.xml File:

XML




<?xml version="1.0" encoding="UTF-8"?>
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
   <localRepository>${user.home}/.m2/repository</localRepository>
   <interactiveMode>true</interactiveMode>
   <offline>false</offline>
   ...
</settings>


2. Central Repository

This is a remote repository available over the internet, whenever a dependency or artifact is not found in the local repository maven triggers a request to this central repository and downloads the dependencies to the local repository. This repository is provided by the Apache Maven group. The url for this central repo is listed as https://repo.maven.apache.org/. There are multiple mirrors available for the central repo, one can make changes on the settings.xml file in maven to use a particular mirror that is officially listed. Some dependency uploads can also be made to the central repo after gaining some permissions.

Settings.xml File:

XML




<?xml version="1.0" encoding="UTF-8"?>
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
   ...
   <mirrors>
      <mirror>
         <id>centeal repo</id>
         <name>repo_name</name>
         <url>maven2</url>
         <mirrorOf>https://repo.maven.apache.org/central</mirrorOf>
      </mirror>
   </mirrors>
   ...
</settings>


3. Internal Repository

These repositories are maintained by the organization where downloads from external sites are prohibited, the organizations can add the details of these internal repositories in the settings.xml file. These repositories are private to the respective organizations. The libraries which are missing on the central repository are added here. All the artifacts or project references that are developed by the organization exist here. The dependencies required are loaded from here and directly to the local repository. If maven can’t find the required dependency from any of the following sources, it throws an error stating “cannot resolve dependency”. To add a new internal remote URL

XML




<?xml version="1.0" encoding="UTF-8"?>
<repositories>
   <repository>
      <id>repo_id</id>
      <url>//for example neveropen.com</url>
   </repository>
</repositories>


 

Here the third local machine has restricted access to external sites, so it uses the internal repo to find the dependencies.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12098 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS