How to add local jar files to Maven project
Sometimes you need to include the custom JAR file or the JAR that you want to use and it doesn’t exist in maven central repository in your Maven project. To resolve this type of problem you can define the local/system JAR file location in the dependency tag.
For example, to connect with Oracle database you need the ojdbc.jar jar file but this file doesn’t exist in the maven central repository. But now you can pass the local jar file location in your pom.xml.
Below dependency code will include the local jar file to your maven project.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>14</version>
<scope>system</scope>
<!-- <systemPath>F:/lib/ojdbc14.jar</systemPath> -->
<systemPath>${basedir}/JARS/ojdbc14.jar</systemPath>
</dependency>${basedir} represents the directory containing pom.xml.
Note: by adding the dependency as
systemscope and refer to it by its full path is not best approach.
References
Similar Posts
- Maven- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- How to enable breadcrumb in Eclipse/STS
- IntelliJ IDEA – Disable Method Chains Inlay Hints
- WAMP/XAMPP Server- .htaccess redirect rule not working on localhost
- wamp- Could not execute menu item (internal error): The service has not been started