How to specify the local repository for packaging in Maven?

To specify a local repository for packaging in Maven, you need to configure it in the project’s pom.xml file. Add the following code under the tag:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <outputDirectory>/path/to/local/repository</outputDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

Replace /path/to/local/repository with the local repository path where you want to place the packaged files. Then, run the mvn package command to output the project package to the specified local repository path.

bannerAds