问题描述
在idea中运行tomcat时报错:
严重: Servlet.service() for servlet [jsp] in context with path [/filter-demo] threw exception [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”] with root cause
解决方案
经排查,发现导入servlet
和jsp
依赖时忘了添加<scope>provided</scope>
,添加一下即可:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
细节决定成败啊!!!