Java编译器级别与安装的Java项目构面的版本不匹配 [英] Java compiler level does not match the version of the installed Java project facet
问题描述
我已经在Eclipse Helios版本下创建了一个新的动态项目,其中JRE版本设置为1.6。
我已经通过点击配置→转换为Maven项目将Maven功能添加到Web应用程序。
I have created a New Dynamic Project under Eclipse Helios Version, where my JRE Version is set to 1.6. I have added Maven capabilities to the Web Application by clicking on Configure → Convert to Maven Project.
添加后,Eclipse问题视图中出现构建错误:
After adding this, a build error appeared in the Eclipse Problems view:
Java compiler level does not match the version of the installed Java project facet.
Unknown Faceted Project Problem (Java Version Mismatch)
请告诉我如何解决此错误(我想让我的JRE版本只有1.6)。
Please tell me how to resolve this error (I want to have my JRE version as 1.6 only).
推荐答案
假设你在Eclipse中使用了m2e插件,需要为 maven-compiler-plugin指定
。 m2e使用这些值来确定项目的Java编译器级别。 POM的片段如下所示:源
和目标
版本为1.6
Assuming that you are using the m2e plugin in Eclipse, you'll need to specify the source
and target
versions as 1.6 for maven-compiler-plugin
. m2e uses these values to determine the project's Java compiler level. A snippet of the POM is shown below:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
或者,您可以指定 maven.compiler.source
和 maven.compiler.target
属性值为1.6,恰好相当于:
Alternatively, you can specify the maven.compiler.source
and maven.compiler.target
properties with values of 1.6, that happen to be the equivalent:
<properties>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
</properties>
这篇关于Java编译器级别与安装的Java项目构面的版本不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!