Eclipse- Dynamic Web Module 3.0 requires Java 1.6 Error

Reprinted from: http://blog.csdn.net/lifuxiangcaohui/article/details/44199763

 

I found that there are several places to solve this problem. This depends on the situation of your project. Here is a summary:

1. Define the version of maven-compile-plugin and the version of source and target in the pom file, that is, insert the following version. I use dynamic web3.0 in my project, so the specific version of java1.7 or above must be used. You can define it according to your own project.

 
   <build>
   
<plugins>
     
<plugin>
       
<groupId>org.apache.maven.plugins</groupId>
       
<artifactId>maven-compiler-plugin</artifactId>
         
<version>3.1</version>
       
<configuration>
             
<source>1.7</source>
             
<target>1.7</target>
       
</configuration>
     
</plugin>
   
</plugins>
</build>

2. Eclipse is not set up when importing the project

1) Right-click the project Properties -> Java Build Path and modify the JRE version to 1.7 

2) Right-click the project Properties -> JavaCompiler to see if the version of the Compiler compliance level is 1.7, if not, change it to 1,7 

3) Right-click the project Properties -> DEployment Assembly to see if Maven Dependencies is added and the corresponding path is the same (some are Webapp, some are WebRoot) 

4) Right click on the project Properties -> Project Facets 

Check Dynamic Web Module and set the Version to 3.0

   Check Java to set the Version to 1.7

In addition, if the Dynamic Web Module cannot be set, you can refer to

How to modify dynamic web module version in eclipse
http://www.cnblogs.com/yezhenhan/archive/2011/10/17/2215279.html   

Three, web.xml header file definition error

The following outdated header file

 
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
   <display-name>Archetype Created Web Application</display-name>
</web-app>

Replace it with the following

 
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                       http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
                       version="3.0">
   <display-name>Archetype Created Web Application</display-name>

</web-app>

4. The version of javaee-api is too low, and the version 6.0 needs to be changed to version 7.0

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

I solved it by the first method

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326151510&siteId=291194637