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>
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>
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:
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!