eclipse中报错The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path。
今天刚引入支付宝沙箱demo后出现了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 → OK。
但是由于Eclipse中serverRuntime Environment中没有Tomcat选项,纠结了好久后开始换思路查找解决方法,最终发现新的解决方法:
原因:eclipse版本不全,缺少javaee组件
在Eclipse中依次点击:
help–>install new software–>在worhwith中选中”oxygen - http://download.eclipse.org/releases/oxygen“(oxygen为eclipse的版本号,找自己相应的版本号)
选中 Web, XML, Java EE and OSGi Enterprise Development 下的 JST Server Adapters,JST Server Adapters Extentions 安装
安装后重启eclipse,这时候就可以在:
window–>preferences–>server–>Runtime Environment –>add–>这时候就可以在Apache中找到Tomcat了。
然后重复最开始的解决方法即可解决相应的问题,问题完美解决
希望能帮助到你喔!