Maven build from local jar Steps

(Last Updated On: December 15, 2017)

We need to create or do maven build sometimes using our local jar.  Today we are going to see the simple steps create the maven build with our local jar instead of the jar from maven repository/custom repositories.

 

Here I mentioned the 4 steps for maven build using our local jars. I tested this easy way and it works awesome. Hope it helps you as well!

Feel free to write if you have some other ways for the same in the below comments section.

 

Here I tested this with jsoup jar, which actually exists in the maven repository, but I downloaded and kept in my project base directory and commented the maven repository dependencies in my pom.xml and configured to take the jar from local and created the maven build.

 

Maven build from local jar Steps:

You can put your jar anywhere in your application and refer that in your pom.xml, as this makes confusion lot of times with the path mention in the pom.xml file, I suggest you to put the jar always where the pom.xml exists.

 

 

  • 1: Placed jsoup-1.7.2.jar inside project folder (same path only pom.xml too exists) — Put your jar in the same place where pom.xml exists
  • 2: Added the below entries with ${project.basedir}/jsoup-1.7.2.jar, here  ${project.basedir} refers the project folder path or where the pom.xml exists.

<dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/jsoup-1.7.2.jar</systemPath>
</dependency>

 

  • 3: Commented the actual maven repository jar artifact id for jsoup-1.7.2.jar in pom.xml
  • 4: Add jsoup-1.7.2.jar to your build path (Right click on the jar -> Build path -> Add to build path) to resolve the compilation issues.

 

Maven build from local jar Steps

 

 

Things to Note:

  1. Ensure your jar has added to your build path to resolve the compilation issues.
  2. Keep same artifact id/group id and version numbers in pom.xml.
  3. Local jar must be available in the project base directory(same path where pom.xml exists).

 

Hello world maven step by step

 

Feel free to comment if you face any issues in the below comments section to help you better.

186 total views, 0 views today

Leave a Reply

Your email address will not be published. Required fields are marked *