Maven: 编译时出现致命错误: 无效目标版本: 1.8
我们刚刚将项目从 升级到 .在我的机器中构建项目时,我收到以下错误。jdk 1.6
jdk 1.8
[错误]未能在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.3:编译(默认编译)异常: 致命错误编译: 无效的目标版本: 1.8 -> [帮助 1]
这是已使用的 maven 编译器插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
我查看了许多帖子,其中大多数都与没有为java_home配置正确的版本有关。我验证了所有这些方面,但找不到任何令人震惊的东西。
Java 版本 -
qadeersmsiphone:main pdubey$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
马文版 -
qadeersmsiphone:main pdubey$ mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 08:22:22-0700)
Maven home: /usr/share/maven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
我检查了在构建项目时,maven使用jdk 1.8
qadeersmsiphone:main pdubey$ mvn install -debug
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 08:22:22-0700)
Maven home: /usr/share/maven
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /Users/pdubey/.m2/settings.xml
[DEBUG] Using local repository at /Users/pdubey/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/pdubey/.m2/repository
[INFO] Scanning for projects...
更新:我可以通过删除pom文件中的maven-compiler-plugin来让它工作(理想情况下,我不想这样做)。我还观察到,即使我删除了这个插件,maven也会默认在我的本地存储库中下载3.3版本的编译器插件。我不确定这个插件中有什么问题,尽管源和目标似乎是正确的。