1.pom.xml文件是正常,编译不存在jar包冲突
首先确保maven中的Tomcat的jar包和本地Tomcat的jar包不冲突,只要在IDEA工程的pom.xml文件中,为导入maven的Tomcat的jar包设置作用范围,即使它们只在编译过程中起作用,而在运行过程中,还是用本地Tomcat的jar包:
在jar包不冲突的前提下,运行Tomcat:run依然报错,错误信息如下:
以下是浏览器访问.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.lang.String cannot be resolved. It is indirectly referenced from required .class files
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
An error occurred at line: 1 in the generated java file
The type java.lang.Class cannot be resolved. It is indirectly referenced from required .class files
An error occurred at line: 23 in the generated java file
The method getName() is undefined for the type Class
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext