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
system
scope and refer to it by its full path is not best approach.
References
Similar Posts
- IntelliJ IDEA – Code reformat and rearrange shortcut keys
- wamp- Could not execute menu item (internal error): The service has not been started
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- IntelliJ IDEA- Generate Getter & Setter Shortcut Key
- svn: There are unfinished transactions detected