解决JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer问题

来源:互联网 发布:贵族徽章 知乎 编辑:程序博客网 时间:2024/05/21 09:53

**

错误1:

**在eclipse中新创建一个web项目的时候项目下的JSP文件中会爆出错误:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path。这个错误就是因为项目中还没有引入servlet的jar包。将jar引入进来就可以解决这个错误了,如果是maven项目则直接引入相关jar即可

    <dependency>        <groupId>javax</groupId>        <artifactId>javaee-web-api</artifactId>        <version>7.0</version>    </dependency>

**

错误2:

**在使用eclipse新创建maven的web项目中当添加servlet的jar包的时候会出现一些错误就是JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer. SpringWebmvc001,这个错误可以通过将项目改为servlet3.0以上版本来解决,因为现在的eclipse通过maven新创建的web项目是servlet2.3版本的,但是在将项目修改3.1版本的时候却又出现了Cannot change version of project facet Dynamic Web Module to 3.1错误,然后就是解决不能转换为3.1的错误了
解决方法:

  1. 将项目根目录中的.setting文件夹中的org.eclipse.wst.common.project.facet.core.xml中的改为1.8,将改为3.1
<?xml version="1.0" encoding="UTF-8"?><faceted-project>  <fixed facet="wst.jsdt.web"/>  <installed facet="java" version="1.8"/>  <installed facet="jst.web" version="3.1"/>  <installed facet="wst.jsdt.web" version="1.0"/></faceted-project>
  1. 将web.xml文件修改为3.1版本(如果项目中没有web.xml可以从别的项目中复制一个过来)
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns="http://xmlns.jcp.org/xml/ns/javaee"     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"     id="WebApp_ID"     version="3.1">  <display-name>testWeb001</display-name>  <welcome-file-list>    <welcome-file>index.html</welcome-file>    <welcome-file>index.htm</welcome-file>    <welcome-file>index.jsp</welcome-file>    <welcome-file>default.html</welcome-file>    <welcome-file>default.htm</welcome-file>    <welcome-file>default.jsp</welcome-file>  </welcome-file-list></web-app>

3.update一下项目,如果使用的是java配置的话,就可以把web.xml删除了不影响使用

4.如果更新项目之后出现了Dynamic Web Module 3.1 requires Java 1.7 or newer 错误,可以将项目的jre版本修改为1.8,然后在更新一下项目
这里写图片描述

5.如果修改完jre,更新项目之后发现jre版本没有改变,这个时候可以在maven配置文件中进行配置

  <build>    <finalName>SpringWebmvc001</finalName>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-compiler-plugin</artifactId>            <configuration>                <source>1.8</source>                <target>1.8</target>            </configuration>        </plugin>    </plugins>  </build>
阅读全文
0 0