简体   繁体   中英

Maven copying Tomcat JARs into webapp WEB-INF/lib directory

I have a very simple webapp published as a WAR file, being developed in Eclipse. I'm using m2e for dependency management. My project, in the Project Facets tab, has the Dynamic Web Module enabled, along with Java . In addition, under my Deployment Assembly I have the Maven dependencies listed, but no inclusion/exclusion options:

在此处输入图片说明

My WAR builds fine, and runs fine in Eclipse. However , the Dynamic Web Module seems to be resulting in my WAR file containing a number of Tomcat JARs, in addition to all my other dependencies:

在此处输入图片说明

I was able to remove tomcat-catalina-7.0.30.jar (not pictured) by including in my POM.xml:

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>

But it seems there must be a way to tell Maven that the entire Tomcat container will be provided at runtime. I don't want to add ~20 provided entries to remove the rest of them.

Look at the POMs of your project. Somewhere, someone added them without the proper scope .

In Eclipse, you can use the POM editor. There is a set of tabs at the bottom of the editor. One reads "Dependency Hierarchy". Here you can search for "tomcat" and m2e will tell you which POMs contain such a dependency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM