How do you specify a repository in Maven?

How do you specify a repository in Maven?

A) By adding a <repository> element within the <repositories> section
B) By adding a <pluginRepository> element within the <repositories> section
C) By adding a <dependency> element within the <repositories> section
D) By adding a <plugin> element within the <repositories> section

Answer:

A) By adding a <repository> element within the <repositories> section

Explanation:

To specify a repository in Maven, you add a <repository> element within the <repositories> section of the pom.xml file. This element defines the URL of the repository where Maven should look for project dependencies.

For example:


<repositories>
    <repository>
        <id>central</id>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>

In this example, the Maven Central Repository is specified as the source for dependencies.

Reference links:

https://www.javaguides.net/p/maven.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top