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

it2022-05-05  159

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

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

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

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

1 <dependency> 2   <groupId>javax.servlet</groupId> 3   <artifactId>servlet-api</artifactId> 4   <scope>provided</scope> 5 </dependency> 6 <dependency> 7   <groupId>javax.servlet</groupId> 8   <artifactId>jsp-api</artifactId> 9   <scope>provided</scope> 10 </dependency>

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

1 <!-- 配置Tomcat插件 --> 2 <plugin> 3 <groupId>org.apache.tomcat.maven</groupId> 4 <artifactId>tomcat7-maven-plugin</artifactId> 5 <configuration> 6 <path>/</path> 7 <port>8080</port> 8 </configuration> 9 </plugin>

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

 

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


最新回复(0)