Fix maven JSTL 1.2.1 dependency so maven-war-plugin doesn't package JARs that offend Tomcat 7

后端 未结 2 1905
一向
一向 2021-01-19 12:02

My setup: jdk 7, Tomcat 7.0.29, ,Eclipse Juno (with m2e[Maven 3.0.4 embedded], m2eclipse-wtp)

I have a Dynamic Web Project with this JSTL dependency:



        
相关标签:
2条回答
  • 2021-01-19 12:44

    Figured it out, the jsp-api was sneaking into the WEB-INF\lib as a transative dependency of the jstl, the fix is to exclude like so.

    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.servlet.jsp.jstl</artifactId>
        <version>${javax.jstl.version}</version>
        <exclusions>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>jsp-api</artifactId>
                <groupId>javax.servlet.jsp</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    
    0 讨论(0)
  • 2021-01-19 12:51

    For version 1.2.1 use:

    <!-- add the selvlet-api that tomcat provides as provided -->
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.servlet.jsp.jstl</artifactId>
        <version>1.2.1</version>
        <exclusions>
             <!-- jstl-api was adding selvlet-api 2.5 and jsp-api-->
            <exclusion>
                <artifactId>jstl-api</artifactId>
                <groupId>javax.servlet.jsp.jstl</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    

    Because if not the jstl-api 1.2 will be added as a dependency. It is the jstl-api that added the jsp-api and servlet-api dependencies.

    0 讨论(0)
提交回复
热议问题