原因是maven默认使用的是Tomcat6,如果配置了JDK1.8,使用tomcat:run命令访问jsp页面时就会有如下报错:
严重: Compilation error org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:342) …… 八月 23, 2019 11:46:24 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet jsp threw exception 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
解决办法:将maven默认的Tomcat的版本调高,即在pom.xml的<plugins>标签中加入:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </plugin>
转载请注明:零五宝典 » IDEA中Maven运行WBE项目报Unable to compile class for JSP解决方法