Include JAR Lib Maven

Include JAR Lib Maven

This is very important to the project if you are using maven to maintain dependencies in your project. Including dependencies to the maven project is quite straight forward where you only use dependencies tag with its group id and artifact id and jar dependencies. But most tricky part is when you are taking final build of your project you will have include all it dependencies in one common location where you can set dependencies.

  • To understand let’s create simple maven project as below:

Include JAR Lib Maven

  • pom.xml:

  • As you see above this project has two dependencies Junit and Log4j and this two should be available in classpath if you are using functaionly fro m these two. Now if you go to command prompt or eclipse and run mvn install command it will create only Jar file and put inside target folder and it does not include those two jars. To include these two jars in some folder and later which running from command prompt you could set its jar class path.

Include JAR Lib Maven

  • To include all static folder and its jar dependencies you will have to modify your pom.xml file as below:

  • Now if you take mvn install it will create lib folder inside target folder and copy all project dependencies jars and as you see I am excluding all static file resources but if you want to include just change it’s name from exclude to include

Include JAR Lib Maven

  • For more information please visit maven documentation here

Leave a Reply

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