Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Tomcat Library to Maven

Tags:

java

maven

tomcat

I am taking my first crack at Maven and ran into a problem. We have an application that is deployed on Tomcat 6. We have several jar files added to the lib folder of tomcat. Then in our build path we add this tomcat library.

How can I add the tomcat library to maven? Is this a bad way to do this? Are there any alternatives?

Thanks in advance

like image 893
blong824 Avatar asked Feb 16 '26 11:02

blong824


1 Answers

Anything in tomcat's lib directory should be a maven dependency with scope provided:

provided
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

Source: Maven Dependency Scope

Example:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

If the libraries are your own, you will have to install or deploy them to a local or remote repository.

like image 88
Sean Patrick Floyd Avatar answered Feb 18 '26 23:02

Sean Patrick Floyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!