Matthias
Matthias

Reputation: 3556

Provding dependencies of scope "provided" for a webapp that will run in tomcat

The description for the "provided" scope of maven dependencies contains this note:

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

Question is if there is a xml snippet available (maybe an official one) that gives me the "provided" dependencies for a specific tomcat version.

Upvotes: 1

Views: 1153

Answers (1)

SilverNak
SilverNak

Reputation: 3381

The thing you are looking for is a Bill of Materials (BOM). This can be imported in the dependencyManagement section of your pom.xml by setting the type and the scope of the dependency to pom and import, respectively.

Unfortunately, Tomcat does not seem to provide an official BOM for its provided dependencies. There is an unofficial version on Github, but depending on what you want to use it for, this may not be the best solution. According to the docs at github, you can us it like this:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>fr.husta.tomcat</groupId>
            <artifactId>tomcat-provided-spec-bom</artifactId>
            <version>8.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

When you use a full-blown JavaEE-Server like JBoss EAP, official BOMs are provided, e. g. this one.

Upvotes: 4

Related Questions