Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including a directory inside web-inf/lib in tomcat classpath

In my webapp; WEB-INF/lib is added in classpath by default which is fine. Now, I want to add spring jar files in my tomcat's classpath. If I put all the jar files inside WEB-INF/lib; it works fine. But if I want to add a directory WEB-INF/lib/spring and put all jar files inside spring directory ; it doesnt work. How can I include WEB-INF/lib/spring in classpath.

I would prefer to make changes in web.xml as that is very localised to my webapp. Surely I will not want to make changes in catalina.properties because there all the jar files are loaded in JVM ( not just added in classpath )

like image 428
Deepak Singhal Avatar asked Sep 14 '25 04:09

Deepak Singhal


1 Answers

You shouldn't care about how the jar files are segregated into the war file: it's only used by the container. Segregating the jar files could be useful in your source project. But then you just need to have a build process (using ant, gradle, whatever) that copies all the jar files from all the subdirectories into WEB-INF/lib. Using ant:

<copy todir="web/WEB-INF/lib" flatten="true">
    <fileset dir="lib">
        <include name="**/*.jar"/>
    </fileset>
</copy>
like image 139
JB Nizet Avatar answered Sep 15 '25 17:09

JB Nizet