Site icon NgDeveloper

Maven build from local jar Steps

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.

 

 

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

 

 

 

 

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.

Exit mobile version