이 콘텐츠는 선택한 언어로 제공되지 않습니다.

4.2. Locating Maven Artifacts at Build Time


Overview

When building projects, Maven implements a simple caching scheme: artifacts are downloaded from remote repositories on the Internet and then cached in the local repository. Figure 4.1, “How Maven Locates Artifacts at Build Time” shows an overview of the procedure that Maven follows when locating artifacts at build time.

Figure 4.1. How Maven Locates Artifacts at Build Time

Locating artifacts at build time

While building a project, Maven locates required artifacts (OSGi bundles, Karaf features, required plug-ins, and so on) as follows:
  1. The first place that Maven looks for artifacts is in the local repository, ~/.m2/repository/ (which is effectively a cache where Maven stores the artifacts it has already downloaded or found elsewhere).
  2. If an artifact is not available in the local repository, Maven attempts to download the artifact from one of the repositories listed in its configuration. This repository list can include both internal and remote repositories.
  3. If the artifact is not available from an internal repository, the next repositories to try are the remote repositories (accessible through HTTP or HTTPS).
  4. When a Maven project is built locally using the mvn install command, the project's Maven artifacts are installed into the local repository.

Adding a remote Maven repository

Remote repositories are configured in the same way as internal repositories, except that they should be listed after any internal repositories.

Adding an internal Maven repository

Maven enables you to specify the location of internal repositories either in your settings.xml file (which applies to all projects) or in a pom.xml (which applies to that project only). Typically, the location of an internal repository is specified using either a file:// URL or a http:// URL (assuming you have set up a local Web server to serve up the artifacts) and you should generally ensure that internal repositories are listed before remote repositories. Otherwise, there is nothing special about an internal repository: it is just a repository that happens to be located in your internal network.
For an example of how to specify a repository in your settings.xml file, see the section called “Adding the Red Hat JBoss Fuse repository”.

Customizing the location of the local repository

Maven resolves the location of the local repository, by checking the following settings:
  1. The location specified by the localRepository element in the ~/.m2/settings.xml file (UNIX and Linux) or C:\Documents and Settings\UserName\.m2\settings.xml (Windows).
  2. Otherwise, the location specified by the localRepository element in the M2_HOME/conf/settings.xml file.
  3. Otherwise, the default location is in the user's home directory, ~/.m2/repository/ (UNIX and Linux) or C:\Documents and Settings\UserName\.m2\repository (Windows).
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat