On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

  • Recent Posts

    October 2010
    M T W T F S S
    « Sep   Nov »
  • Subscribe Options

  • Awards

  • Most Valuable Blogger @ DZone
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 175 other followers

  • Follow MyThinkPond on
  • Blog Stats

    • 366,804 hits
  • General Options

Add custom jars under “\WEB-INF\lib” in a Maven project

Posted by Venkatt Guhesan on October 2, 2010

The answer is a lot simpler than you think. But before we explore the answer, I should warn you that this approach is not what is recommended by Maven. Maven builds upon consistency and structure and this process goes away from that methodology. In Maven, you can take each of your jars\libraries and add them to your local repository and then include them as needed in your projects. If you want to go the proper route here’s how you do it. This keeps a consistent version in all your projects and can allow you to gracefully update the library as new versions become available.

But if you still want to go ahead and add these custom jars in your project then follow these steps:

1. Create a “lib” folder under your project like this: “\src\main\webapp\WEB-INF\lib”
2. Copy needed “jars” etc that you want included inside your WAR bundle folder.
3. Invoke your maven build as you normally do. I use “mvn install”, which creates builds the war file.

If you examine the WAR file, your jars that you included in step-1 and step-2 will be there.


3 Responses to “Add custom jars under “\WEB-INF\lib” in a Maven project”

  1. Saeid said

    Doesn’t work!

  2. Gunjan said

    This will never work as though we thought it will work war will be generated true but without including the jars in it that is why the question was asked.

  3. […] back and doing a lot of googling, I find  this site.  This is a three step process for copying the Jars where step 2 is “Copy the Jars”. […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: