> For the complete documentation index, see [llms.txt](https://maven3.kengo-toda.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maven3.kengo-toda.jp/primer/maven-repository.md).

# Mavenリポジトリ

JARなどの成果物やJavadocをライブラリを整理してまとめておく場所のことを、Mavenリポジトリと呼びます。 パブリックリポジトリ、ローカルリポジトリ、プライベートリポジトリの3種類があります。

![3種のリポジトリの関係](/files/-LIdO_hQLuvZ_WJi8N8H)

## パブリックリポジトリ

パブリックリポジトリ（public repository）とは、誰でもインターネット経由でアクセス可能なリポジトリのことです。 Mavenを使う際は、セントラルリポジトリを主に使うことになります。

### セントラルリポジトリとは

Mavenがデフォルトで利用するリポジトリです。たくさんのライブラリが公開されています。

* [Maven central repository](http://search.maven.org/)

## プライベートリポジトリとは

何らかの理由でセントラルリポジトリにライブラリを公開したくない場合、自分でリポジトリを用意して利用できます。このリポジトリのことをプライベートリポジトリと呼びます。WebDAVが使えるサーバならなんでもプライベートリポジトリとして使えますが、Apache Archivaや[Nexus](http://www.sonatype.org/nexus/)などの管理機能をもつウェブアプリケーションを使うと便利です。

### プライベートリポジトリを使うには

プライベートリポジトリをセットアップしたら、[pom.xmlに使用するプライベートリポジトリのURLを明記する](http://maven.apache.org/guides/mini/guide-multiple-repositories.html)必要があります。

```markup
<repository>
  <id>my-repo1</id>
  <name>your custom repo</name>
  <url>http://jarsm2.dyndns.dk</url>
</repository>
```

## リモートリポジトリとは

リモートリポジトリ（remote repository）とは、パブリックリポジトリとプライベートリポジトリを合わせた呼称です。 次に説明するローカルリポジトリの対義語といえます。

## ローカルリポジトリとは

mvnコマンドを実行したマシンにあるディレクトリのことです。デフォルトでは`~/.m2/repository`が利用されます。他のリポジトリからダウンロードしたライブラリを保管したり、`install`ゴールでJARをインストールしたりするために使われます。

基本的にMavenは、ライブラリを取得するときにまずローカルリポジトリを確認し、そこになかった場合にのみリモートリポジトリを見に行きます。 リモートリポジトリにも公開されていないライブラリを使う場合には、まず `mvn install` でそのライブラリをプライベートリポジトリにインストールしてやるときちんと使うことができます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://maven3.kengo-toda.jp/primer/maven-repository.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
