关于dependency的scope

provided的含义: whatever version you specify is used at compile time and for testing. At runtime it is assumed to be provided by your runtime container, e.g. Jetty.

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

javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/jasper/servlet/JasperLoader) previously initiated loading for a different type with name “javax/servlet/http/HttpServletRequest”

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

解决:添加<scope>provided</scope>

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



 
posted @ 2012-05-23 17:02  highriver  阅读(551)  评论(0编辑  收藏  举报