Eclipse JRE系统库[J2SE-1.5] [英] Eclipse JRE System Library [J2SE-1.5]

查看:528
本文介绍了Eclipse JRE系统库[J2SE-1.5]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse EE 3.7,安装了m2e插件。我在Eclipse中设置了JDK7。
当我导入maven项目时,JRE设置为 JRE系统库[J2SE-1.5] ,所以我有编译问题与java 6相关的东西。相反,我希望eclipse中的JRE默认设置为JRE 系统库[J2SE-1.6]



我尝试在第一个屏幕上的eclipse File - > new - > Java项目中打开一个新项目,我有一个选项可以选择JRE,第三个选项是使用默认JRE(当前为'jdk1.7.0_03' )从此我可以看到Eclipse中的默认JRE是1.7,但是当我导入新的Maven项目时,JRE设置为



任何帮助,我该怎么做?

解决方案

问题不在于Eclipse,而是与您正在导入的项目。 m2e将把项目的JRE设置为匹配maven项目。 POM指定JRE版本,如果不存在,则默认为1.5。您需要在POM中:

 < build> 
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.0< / version>
< configuration>
< source> 1.7< / source>
< target> 1.7< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>


I'm using Eclipse EE 3.7 with m2e plugin installed. I have JDK7 set in eclipse. When I import maven projects, the JRE is set to JRE System Library [J2SE-1.5], So i have compilation issues with java 6 related stuff. Instead I want the JRE in eclipse to be by default set to JRE System Library [J2SE-1.6]

When i try to open a new project in eclipse File -> new -> Java project on the first screen i have an option to choose JRE and the third option is Use default JRE (currently 'jdk1.7.0_03')

From this i can see that the default JRE in Eclipse is 1.7, but when i import new Maven projects, the JRE is set to 1.5 by default.

Any help, how can i do this?

解决方案

The problem is not with Eclipse, but with the projects you're importing. m2e will set the project's JRE to match the maven project. The POM specifies the JRE version, and this is defaulted to 1.5 if not present. You need this in the POM:

<build>
     <plugins>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                   <source>1.7</source>
                   <target>1.7</target>
                </configuration>
        </plugin>
    </plugins>
</build>

这篇关于Eclipse JRE系统库[J2SE-1.5]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆