maven eclipse-不受支持的major.minor版本52.0
我正在使用ApacheMaven3.2.3来编译我的java项目 当我使用命令行启动编译时,使用maven eclipse-不受支持的major.minor版本52.0,eclipse,maven,unsupported-class-version,Eclipse,Maven,Unsupported Class Version,我正在使用ApacheMaven3.2.3来编译我的java项目 当我使用命令行启动编译时,使用 mvn clean compile 然后它就完美地工作了 但当我从eclipse(LUNA)运行maven build时,它总是失败,并出现以下错误: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project MSD
mvn clean compile
然后它就完美地工作了
但当我从eclipse(LUNA)运行maven build时,它总是失败,并出现以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project MSDPEx: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile: java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 52.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.5.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/rvnath/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.5.1/maven-compiler-plugin-2.5.1.jar
[ERROR] urls[1] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-utils/3.0/plexus-utils-3.0.jar
[ERROR] urls[2] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-api/1.9.1/plexus-compiler-api-1.9.1.jar
[ERROR] urls[3] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/1.9.1/plexus-compiler-manager-1.9.1.jar
[ERROR] urls[4] = file:/home/rvnath/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/1.9.1/plexus-compiler-javac-1.9.1.jar
[ERROR] urls[5] = file:/home/rvnath/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
eclipse和maven的配置有问题吗?如果是,我如何解决这个问题
如果有帮助,我的环境如下:
OS: Ubuntu 14.10
JDK: java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~utopic1)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
Eclipse installed JRE's: java-7-openjdk-amd64 (default)
在过去的2…3周里,这个问题一直困扰着我 这类问题已经被问了好几次,也有很多答案。但是也发布我的答案,这样有这种情况的人可能会受益 最后我发现我的系统也安装了jdk1.8,maven的cmdline启动使用的是这个版本,而eclipse使用的是1.7。因此,我做了以下工作:
现在我可以编译这个项目了,尽管我不知道确切的原因,为什么它不能用jdk1.7编译 首先。如果您使用的是Maven,那么事实就在pom文件中,而不是Eclipse中。因此,您必须在Maven中解决问题,而不是在Eclipse中 首先,您必须将maven编译器插件更新为3.2或3.3版。并按如下方式进行配置:
[...]
[...]
org.apache.maven.plugins
maven编译器插件
3.3
1.7
1.7
[...]
[...]
您应该从命令行而不是eclipse中检查构建。此外,您应该知道使用
源代码
、目标代码
选项和JDK之间的区别。上述方法对我不起作用,但这确实起到了作用。
添加到您的pom.xml
<project ....>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
1.7
1.7
其中1.7是您打算使用的Java版本。这将覆盖maven编译器设置,因此最好从这里进行调试