"The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path"问题的解决方法(eclipse+tomcat)
最近用eclipse新建JSP项目,完成后出现小红叉,点击显示“The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path”。花了不少时间才解决。这里记录一下:
1. 确认eclipse中server的运行环境是否有配置,设置方法为:Window → Preferences → Server → Runtime Environments →Add → 选择Apache的版本后点Next,再填入你apache tomcat软件的安装(解压后)目录。
2.右击web工程 → Build Path → Configure build path... → Java Build Path → Libraries → Add Libray... → Server Runtime →Next> → Apache Tomcat Server →Finish。
3. 切换到Java Build Path界面中的Orader and Export,勾选Tomcat。
4.右击web工程 → 属性 → Project Facets → 点击右侧tab选择Runtimes → 勾选tomcat → 但到这里问题还没解决。
5.查tomcat的环境变量的配置信息:发现path里只配置了bin,没有配置lib,所以立刻在 Path 后添加 ;%CATALINA_HOME%\lib;%CATALINA_HOME%\bin; 保存后,小红叉消失了!
6.run asserver运行一下,报错:The server cannot be started because one or more of the ports are invalid. Open the server editor and correct the invalid ports
7.发现是装Tomcat的时候server shutdown port没有设置成8005,而是-1,所以导致eclipse调不起来。要对配置文件进行修改:在tomcat安装目录下的conf里,找到server.xml,把server shutdown 的port从-1,改成8005.保存。(在这一步操作时一定要先关闭eclipse,不然又掉坑里了,切记!)
8.重启eclipse,run as server运行终于ok了。
————————————————
版权声明:本文为CSDN博主「bluetata」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/dietime1943/article/details/75127417