前言:发现国内网站关于这个问题的解决信息较少(我找好久没找到),所以就记录下来方便后人查阅吧。
问题描述:使用jetty插件来进行mvn install或者jetty:run时,报以下错误:
java.lang.ClassNotFoundException:org.apache.jasper.runtime.JspApplicationContextImpl
解决办法:
在pom文件中添加以下依赖:
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.0.0</version>
</dependency>
我添加后再进行mvn install或者jetty:run就不报错了。当然有些人是端口已被占的异常,这个容易看出也容易解决,这里不做描述了。
追加:
添加以上依赖后,若用tomcat启动项目可能会报以下错误:
java.lang.ClassCastException: org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.el.ELContextImpl] with root cause
这是与tomcat的lib下的包冲突导致,解决办法是修改tomcat里的context.xml文件,在context 元素下添加
<Loader delegate="true" />
该冲突还有另外一种解决方案,
参考:http://blog.csdn.net/sunqp0208/article/details/24701937