maven项目中出现Unable to compile class for JSP错误的解决办法

:在maven项目中访问jsp页面的时候,有的时候会出现下面的这种情况:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

二:首先需要看下是否加入了下面这两个依赖,没加的话加上去

 1 <dependency>
 2   <groupId>javax.servletgroupId>
 3   <artifactId>servlet-apiartifactId>
 4   <scope>providedscope>
 5 dependency>
 6 <dependency>
 7   <groupId>javax.servletgroupId>
 8   <artifactId>jsp-apiartifactId>
 9   <scope>providedscope>
10 dependency>

再然后查看是否配置了如下tomcat插件:

1 
2 <plugin>
3     <groupId>org.apache.tomcat.mavengroupId>
4     <artifactId>tomcat7-maven-pluginartifactId>
5     <configuration>
6         <path>/path>
7         <port>8080port>
8     configuration>
9 plugin>

添加了之后若还是出现上面那个异常,可以看下在Run as中的Maven build中输入是不是tomcat:run这个命令,是的话可以改下命令为tomcat+配置的tomcat的版本的版本号,例如配置的是tomcat7的话,那么将命令改成tomcat7:run即可。

 

转载于:https://www.cnblogs.com/AI-xiaocai/p/10862738.html

你可能感兴趣的:(maven项目中出现Unable to compile class for JSP错误的解决办法)