[解決]Maven項目出現 The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path in Eclipse問題

如在建立或匯入 Maven 項目到 Eclipse 開發環境中,看到出現 The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path in Eclipse 錯誤訊息,代表項目的 class path 找不到 http-servlet ,我們便需要把 http-servlet 加入至 class path。

 

解決方式:有兩種加入 class path 的方式。

1) 加入至 target runtime ,在項目列表右鍵單擊項目的選單,選擇 properties,選擇 Project Facets > Runtimes ,如 Runtimes 下已經有 servlet runtime 的依懶包,只需要直接勾選便可。如沒有,則需要點擊 New 按鈕新增後再勾選。

2) 直接在 Maven 的 pom.xml 下加入依懶配置。
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
</dependency>

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*

驗證碼 * Time limit is exhausted. Please reload CAPTCHA.

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料