MAVEN ERROR : Dynamic Web Module 3.0 requires Java 1.6 or newer

问题:

  在eclipse中,通过Maven->Update Project更新项目后,出现Dynamic Web Module 3.0 requires Java 1.6 or newer错误提示,发现项目Java Compiler中的版本回到1.5。

 

原因:

  其实在Maven官方文档中,Maven 3.0 source和target的默认设置都是1.5,与运行Maven时的JDK版本无关,除非在项目的POM文件中显示的指定一个版本,否则每次更新后都会使用编译器默认的source/target版本1.5。

 

解决方案:

  在pom中指定JDK版本,在哪儿指定,compiler-plugin中。

<!-- 官方文档 -->
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html -->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <!-- 指定source和target的版本 -->                
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

 

posted @ 2016-05-09 14:13  二郎那个三郎  阅读(232)  评论(0)    收藏  举报