Home > Java > javaTutorial > How to Integrate Custom External JARs into Your Maven Project for Version Control?

How to Integrate Custom External JARs into Your Maven Project for Version Control?

Susan Sarandon
Release: 2024-10-29 10:20:02
Original
500 people have browsed it

How to Integrate Custom External JARs into Your Maven Project for Version Control?

Custom External JAR Integration with Maven

Adding external JAR files to a Maven project is a common task, especially when working with non-public repositories. For your specific scenario, we will explore two options, both ensuring both your project and the library are version controlled.

1. In-Project Repository:

To maintain the library within your project and version control, you can create an in-project repository. Add the following to your pom.xml:

<code class="xml"><repository>
    <id>in-project</id>
    <name>In Project Repo</name>
    <url>file://${project.basedir}/libs</url>
</repository>

<dependency>
    <groupId>stuff</groupId>
    <artifactId>library</artifactId>
    <version>1.0</version>
</dependency></code>
Copy after login

This will add the lib directory under your project folder as a repository and automatically install the library.

2. System Scope with External Path:

If you prefer to store the JAR externally, you can use the system scope:

<code class="xml"><dependency>
    <groupId>stuff</groupId>
    <artifactId>library</artifactId>
    <version>1.0</version>
    <systemPath>${lib.location}/MyLibrary.jar</systemPath>
    <scope>system</scope>
</dependency></code>
Copy after login

Specify the system path of the JAR file using the ${lib.location} property, but you won't need to run mvn install:install-file.

Eclipse Issue Resolution:

If Eclipse doesn't recognize the dependency after adding it to the POM, you can try the following:

  • Clean and rebuild the project (right-click > Clean)
  • Manually add the JAR file to your Eclipse project classpath (right-click > Properties > Java Build Path)
  • Refresh the Maven dependencies (Window > Show View > Other > Maven)

The above is the detailed content of How to Integrate Custom External JARs into Your Maven Project for Version Control?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template