Rami Del Toro
Rami Del Toro

Reputation: 1150

How to define a repository in Maven pom.xml

How can we define a repository in the pom.xml?

For example if dependency is not found in the repository defined in settings.xml then search for the dependency in the repository defined in pom.xml.

An example on how this can be achieved would be great.

I am aware that placing repositories in the pom.xml is not a good option, but circumstances are pushing for this.

Upvotes: 3

Views: 6841

Answers (2)

user180100
user180100

Reputation:

From the documentation (example reproduced as is here):

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <repositories>
    <repository>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
      </snapshots>
      <id>codehausSnapshots</id>
      <name>Codehaus Snapshots</name>
      <url>http://snapshots.maven.codehaus.org/maven2</url>
      <layout>default</layout>
    </repository>
  </repositories>
  <pluginRepositories>
    ...
  </pluginRepositories>
  ...
</project>

Upvotes: 2

bedrin
bedrin

Reputation: 4586

<repositories>
    <repository>
      <id>java.net</id>
      <url>https://maven.java.net/content/repositories/public/</url>
    </repository>
</repositories>

Upvotes: 5

Related Questions