The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误

时间:2023-12-05 11:58:32

1、异常信息

  创建maven web项目时,出现 The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误。

2、异常截图:

The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误

2、错误分析:

  缺少javaEE jar 包。
  javaEE jar 包在哪里?
  javaEE 是SUN公司定义的一大堆接口,是一系列的标准;
  谁实现它谁就为这些接口提供jar文件包;而我们知道tomcat就实现了这些接口,如下图:
The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误
3、解决办法:
添加 web 容器即可。
方法一:在pom.xml文件里添加tomcat的坐标。
The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误

方法二:直接上图

The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误

The superclass “javax.servlet.http.HttpServlet" was not found on the Java Build Path错误