What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Maven repository” can mean three different things: the local cache Maven uses on one machine, a remote source Maven downloads dependencies from, or a destination where you publish your artifacts. Configuring Maven to use an existing location can take minutes; operating a reliable shared repository also requires infrastructure and access policies.

Choose the repository setup you need

Need What to configure Where it applies
Use Maven on one machine The local repository, which Maven uses as a cache That machine
Download dependencies from another source A remote repository in the project POM, or machine-level settings where appropriate Builds that use the configured source
Share or publish artifacts for a team A remote repository location; typically use repository-management software for internal hosting Team or organization

Maven normally downloads missing dependencies from Maven Central. A local repository is a directory on the machine running Maven; by default it is ${user.home}/.m2/repository. It stores downloaded artifacts and temporary build artifacts. See Apache Maven’s Introduction to Repositories and Configuring Maven.

Use Maven’s local repository

If you only need Maven for your own builds, no shared repository needs to be set up: Maven uses its local repository by default. You can change its location through user-level settings.xml. This changes the cache location, not the location where a team can retrieve published artifacts. Consult Maven’s settings configuration guide for the applicable setting.

Add a remote repository for downloads

Use a project-level <repositories> entry when the project needs dependencies from an additional remote source. Maven repository locations may use protocols such as HTTPS or file://. A repository entry tells Maven where to retrieve artifacts; it does not tell Maven where to upload your project’s build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, add a repository inside the project’s top-level <project> element, substituting the repository ID and URL supplied by its administrator:

<repositories>
  <repository>
    <id>team-dependencies</id>
    <url>https://repo.example.com/maven/releases</url>
  </repository>
</repositories>

repo.example.com is an example domain, not a real repository address. For settings that affect Maven on a particular machine or build agent, including mirrors, use settings.xml rather than treating a project repository declaration as a universal client configuration. Maven documents these options in Configuring Maven.

Configure a destination for publishing

To publish a Maven-built project, configure <distributionManagement> in the project POM. It identifies the deployment destination, which is a different job from the download sources in <repositories>. A release destination and a snapshot destination can be specified separately; use the URLs and repository types required by your hosting service.

<distributionManagement>
  <repository>
    <id>team-releases</id>
    <url>https://repo.example.com/maven/releases</url>
  </repository>
  <snapshotRepository>
    <id>team-snapshots</id>
    <url>https://repo.example.com/maven/snapshots</url>
  </snapshotRepository>
</distributionManagement>

Replace the example URLs and IDs with values from the repository administrator. The upload destination and the URL clients use to download artifacts can differ, depending on the server and upload protocol. The Maven POM Reference explains distributionManagement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Store credentials in settings.xml

Keep repository credentials out of a shared POM. In the relevant user or CI build agent’s settings.xml, add a <server> entry whose <id> exactly matches the ID of the publishing destination that needs authentication:

<servers>
  <server>
    <id>team-releases</id>
    <username>YOUR_USERNAME</username>
    <password>YOUR_TOKEN_OR_PASSWORD</password>
  </server>
</servers>

The credential fields and token format depend on the hosting provider; follow its current instructions and protect the settings file and CI secrets. Maven’s Security and Deployment Settings guide describes the server-ID matching behavior.

Deploy and verify an artifact

  1. Configure the destination: Add the appropriate <distributionManagement> entry to the project POM and credentials to the build user’s settings.xml, with matching IDs.
  2. Deploy a Maven-built project: Run mvn deploy. The deploy lifecycle phase builds and deploys the project according to its configuration.
  3. Deploy an artifact built elsewhere: Use the Maven Deploy Plugin’s deploy:deploy-file goal, supplying the artifact and the destination details required by the plugin and repository.
  4. Check retrieval: Confirm the artifact appears in the remote repository, then try resolving it from a clean client or another machine configured to access that repository.

See Usage – Apache Maven Deploy Plugin for deployment details.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What a shared repository requires beyond an address

A directory or URL that follows Maven repository layout is not automatically a managed team service. For internal hosting, Maven recommends repository-management software so artifacts can be retrieved as needed; avoid copying or scraping a full Maven Central mirror. The hosting implementation determines details such as authentication, permissions, retention, backups, and release policies, so confirm those requirements with the team operating it. Maven’s repository guide discusses internal repository setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Local cache versus shared service: The default local repository serves the Maven process on one machine; a team needs a remotely accessible location.
  • Downloading versus publishing: Use <repositories> for dependency sources and <distributionManagement> for deployment destinations.
  • Anonymous versus authenticated access: Public or internal access rules vary by host; when authentication is needed, configure credentials through a matching server ID in settings.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.