maven项目中jsp不能编译情况(Unable to compile class for JSP)

来源:互联网 发布:网络通信有哪些 编辑:程序博客网 时间:2024/06/07 20:45

在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

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

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


再就是若你配置了tomcat插件如下:

<build>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/</path>
<port>8082</port>
</configuration>
</plugin>
</plugins>
</build>

改了还是出现上面那个异常的话你可以看下你在Run as中的Maven build中输入的命令是否直接是tomcat:run这个命令,是的话可以改下命令为tomcat+你配置的tomcat的版本的版本号,例如你配置的是tomcat7的话那么你就可以将命令改成tomcat7:run

原创粉丝点击