Dynamic Web Module 3.0 requires Java 1.6 or newer
Description
在使用 Eclipse 創建 Maven 項目的時候報錯?Dynamic Web Module 3.0 requires Java 1.6 or newer,已經確認了 JRE System Library 和 Java Compiler 的版本都是 jdk1.7.0_75,但這個錯始終沒有消除。
?
Caused By
當前 Maven 默認的 source 設置是 1.5,target 設置是 1.5,不依賴于你 run Maven 所使用的 jdk 版本。如果你想改變這些默認值,你應該按照這里 Setting the -source and -target of the Java Compiler?設置 source 和 target。
Solution
有時你可能需要把一個項目編譯成和你當前使用的 jdk 不同的版本。javac 可以接受命令 -source 和 -target。Compiler Plugin 也可以在編譯期間提供這種選擇。例如,如果你想啟用斷言( -source 1.4 ) 并且想使用 JVM1.4 編譯( -target 1.4 ),你可以在 POM 文件中加入:
1 <project> 2 [...] 3 <build> 4 [...] 5 <plugins> 6 <plugin> 7 <groupId>org.apache.maven.plugins</groupId> 8 <artifactId>maven-compiler-plugin</artifactId> 9 <version>3.3</version> 10 <configuration> 11 <source>1.4</source> 12 <target>1.4</target> 13 </configuration> 14 </plugin> 15 </plugins> 16 [...] 17 </build> 18 [...] 19 </project>所以在這里我們只需把版本設置為 1.7 即可:
1 <build> 2 <plugins> 3 <plugin> 4 <groupId>org.apache.maven.plugins</groupId> 5 <artifactId>maven-compiler-plugin</artifactId> 6 <version>3.1</version> 7 8 <configuration> 9 <source>1.7</source> 10 <target>1.7</target> 11 </configuration> 12 </plugin> 13 </plugins> 14 </build>Reference
- Apache Maven Compiler Plugin
- Setting the?-source?and?-target?of the Java Compiler
?
轉載于:https://www.cnblogs.com/yuxiaoqi/p/4862211.html
總結
以上是生活随笔為你收集整理的Dynamic Web Module 3.0 requires Java 1.6 or newer的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery ajax json 数据的
- 下一篇: RestSharp .net 轻量级re