新建maven指定jdk版本-eclipse新建maven項目報錯The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path的解決方案


具體表現為:

使用Eclipse+Maven建立了一個Javaweb工程,JSP頁面頂端出現“紅色”的報錯信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path。

解決方法:

在pom.xml中的  <build></build>中  添加:

    <plugins>
        <!-- 編碼和編譯和JDK版本 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>utf8</encoding>
            </configuration>
        </plugin>
    </plugins>

 然后Maven > Update project即可

 

如果報錯:

Java compiler level does not match the version of the installed Java project facet.    xxx        Unknown    Faceted Project Problem (Java Version Mismatch)

可以:項目--properties---project Facets設置java文件的版本為 1.8(自己對應上面步驟的jdk)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM