Let's look at one of the most common examples:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
This example shows that your project has a junit dependency. You might ask: Where does this dependency come from? Where is the JUnit jar?
A dependency is a reference to a artifact in the repository. The Pom defines a dependency, which is executed by the dependency GroupID, Artifactid and version, to search it from repository. You don't have to be in the Pom.xml to indicate which repository,maven the dependancy from will first find the local repository, if the local repository has dependancy that the artifact references, Use it, if not, search all the remote repository you set, and if you find it, download it to the local repository. By default, the artifact is usually download from the repository (HTTP://WWW.IBIBLIO.ORG/MAVEN2). If your pom.xml defines multiple remote repository, then try to download them from remote repository sequentially.
For example, MAVEN will check the local repository to see if there is a desired junit artifact, if not, from remote repository download to local repository. At this point, the artifact directory structure in the local repository contains: