In Eclipse Juno, I installed the latest m2e plugin (1.2.20120903-1050). In preferences, I have added jdk1.7.0_11 in Java -> Installed JREs -> Add, and then specified the location (C:\Program Files\Java\jdk1.7.0_11
). When I create a new Maven project and run it, I get a warning:
在Eclipse Juno中,我安装了最新的m2e插件(1.2.20120903-1050)。在首选项中,我在Java中添加了jdk1.7.0_11——>安装了JREs ->添加,然后指定了位置(C:\程序文件\Java\jdk1.7.0_11)。当我创建一个新的Maven项目并运行它时,我得到一个警告:
Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
构建路径指定执行环境J2SE-1.5。工作区中没有安装与此环境完全兼容的JREs。
I am not sure how to resolve this.
我不知道该如何解决这个问题。
I believe it is a Maven problem because I do not have this error when I run normal Java projects. I read here that I should change the "maven-compiler-plugin.pom" and change the source and target from 1.5 to something more appropriate. In my case, 1.7. I have done this, but I still get the warning.
我认为这是一个Maven问题,因为我在运行普通Java项目时没有这个错误。我在这里读到我应该更改“maven-compiler- compiler-plugin”。将源和目标从1.5更改为更合适的。在我的例子中,1.7。我这样做了,但我还是得到了警告。
9 个解决方案
#1
41
- Right-click on your project
- 右键单击您的项目
- Click Properties
- 单击“属性”
- Click the "Java Compiler" option on the left menu
- 单击左侧菜单上的“Java编译器”选项
- Under JDK compliance section on the right, change it to "1.7"
- 在右侧的JDK遵从性部分中,将其更改为“1.7”
- Run a Maven clean and then Maven build.
- 运行Maven清理然后Maven构建。
#2
107
All of the answers above may work for the time being but whenever you run maven on the command line or Maven → Update project… the JDK will be reset, this was also the question as I understand it.
上面所有的答案可能暂时工作,但只要在命令行中运行maven或maven→更新项目…JDK将重置,这也是我理解的问题。
To fix this for good add the following code to your pom file. Remember to do a Maven → Update project… afterwards or mvn clean compile
at the command line.
要修复这个问题,请将以下代码添加到pom文件中。记得要做一个Maven→更新项目…后来或mvn清洁在命令行编译。
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
#3
28
I know this is an old topic. I had the same problem. I tested all the answers about this topic. And nothing worked here... but i found another solution.
我知道这是个老话题。我也有同样的问题。我测试了关于这个话题的所有答案。而不是在这里工作…但我找到了另一个解决办法。
Go to pom->overview and add these to you properties:
转到pom->总览,并添加这些属性:
- Name: "maven.compiler.target" Value: "1.7"
- 名称:“maven.compiler.target”价值:“1.7”
and
和
- Name: "maven.compiler.source" Value: "1.7"
- 名称:“maven.compiler.source”价值:“1.7”
Now do a maven update.
现在进行maven更新。
#4
9
For imported maven project and JDK 1.7 do the following:
对于导入的maven项目和JDK 1.7,请执行以下操作:
- Delete project from Eclipse (keep files)
- 从Eclipse中删除项目(保存文件)
- Delete .settings directory, .project and .classpath files inside your project directory.
- 删除项目目录中的.settings目录、.project和.classpath文件。
-
Modify your pom.xml file, add following properties (make sure following settings are not overridden by explicit maven-compiler-plugin definition in your POM)
修改您的砰的一声。xml文件,添加以下属性(确保POM中显式maven-compiler-plugin -plugin定义不覆盖以下设置)
<properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties>
-
Import updated project into Eclipse.
将更新的项目导入Eclipse。
#5
5
I'm using Juno 4.2 with latest spring, maven plugin and JDK1.6.0_25.
我正在使用Juno 4.2与最新的spring、maven插件和JDK1.6.0_25。
I faced same issue and here is my fix that make default after each Eclipse restart:
我遇到了同样的问题,以下是我在每次Eclipse重启后默认的修复:
- List item
- 列表项
- Right-click on the maven project
- 右键单击maven项目
- Java Build Path
- Java构建路径
- Libraries tab
- 库选项卡
- Select current wrong JRE item
- 选择当前错误的JRE项
- Click Edit
- 点击编辑
- Select the last option (Workspace default JRE (jdk1.6.0_25)
- 选择最后一个选项(工作区默认JRE (jdk1.6.0_25)
#6
1
I was facing the same issue. In pom.xml I have specified maven compiler plugin to pick 1.7 as source and target. Even then when I would import the git project in eclipse it would pick 1.5 as compile version for the project. To be noted that the eclipse has installed runtime set to JDK 1.8
我也面临着同样的问题。砰的一声。我指定了maven编译器插件来选择1.7作为源和目标。即使这样,当我在eclipse中导入git项目时,它也会选择1.5作为项目的编译版本。需要注意的是,eclipse已经将运行时设置为JDK 1.8
I also checked that none of the .classpath .impl or .project file is checked in git repository.
我还检查了git仓库中没有检查.classpath .impl或.project文件。
Solution that worked for me: I simply deleted .classpath files and did a 'maven-update project'. .classpath file was regenerated and it picked up 1.7 as compile version from pom file.
对我有用的解决方案:我简单地删除了.classpath文件,做了一个“maven-update project”。
#7
1
If you are getting following type of error
如果你有以下类型的错误
Then do the following steps-->>
然后执行以下步骤——>>
- Go to Windows. Then select Preferences, in Which select java(on the left corner).
- 去窗口。然后选择Preferences,在其中选择java(在左上角)。
- In java select Installed JREs and check your JRE(if you have correctly installed jdk and defined environment variables correct then you will see the current version of the installed java here)as shown -
- 在java中选择install JREs并检查您的JRE(如果您正确安装了jdk和定义的环境变量,那么您将在这里看到安装的java的当前版本)
(I have Java 8 installed) Check the check box if it is not checked. Click apply and close.
(我已经安装了Java 8)如果没有选中,请选中复选框。单击apply和关闭。
Now Press Alt+Enter to go into project properties,or go via right clicking on project and select Properties.
现在按Alt+Enter进入项目属性,或者通过右键单击项目并选择properties。
In Properties select Java Build Path on left corner
在属性中,在左边选择Java构建路径
Select Libraries
选择库
And click edit(after selecting The JRE System Library...) In edit Click and select Workspace default JRE. Then click Finish
并单击edit(在选择JRE系统库之后…)在编辑单击并选择Workspace default JRE。然后单击Finish
In Order and Export Check the JRE System Library.
按顺序导出JRE系统库。
Then Finally Apply and close Clean the project and then build it.
最后应用并关闭项目,然后构建它。
Problem Solved..Cheers!!
问题解决了,干杯! !
#8
0
When creating a maven project in eclipse, the build path is set to JDK 1.5 regardless of settings, which is probably a bug in new project or m2e.
在eclipse中创建maven项目时,无论设置如何,构建路径都被设置为JDK 1.5,这可能是新项目或m2e中的一个bug。
#9
-1
I got an error in Eclipse Mars version as "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
我在Eclipse Mars版本中有一个错误,因为“构建路径指定执行环境J2SE-1.5”。工作区中没有安装与此环境完全兼容的JREs。
To resolve this issue, please do the following steps, "Right click on Project Choose Build path Choose Configure Build path Choose Libraries tab Select JRE System Library and click on Edit button Choose workspace default JRE and Finish
要解决这个问题,请执行以下步骤:“右键单击项目选择构建路径选择配置构建路径选择库选项卡选择JRE系统库,单击编辑按钮选择工作区默认JRE和Finish
Problem will be resolved.
问题将被解决。
#1
41
- Right-click on your project
- 右键单击您的项目
- Click Properties
- 单击“属性”
- Click the "Java Compiler" option on the left menu
- 单击左侧菜单上的“Java编译器”选项
- Under JDK compliance section on the right, change it to "1.7"
- 在右侧的JDK遵从性部分中,将其更改为“1.7”
- Run a Maven clean and then Maven build.
- 运行Maven清理然后Maven构建。
#2
107
All of the answers above may work for the time being but whenever you run maven on the command line or Maven → Update project… the JDK will be reset, this was also the question as I understand it.
上面所有的答案可能暂时工作,但只要在命令行中运行maven或maven→更新项目…JDK将重置,这也是我理解的问题。
To fix this for good add the following code to your pom file. Remember to do a Maven → Update project… afterwards or mvn clean compile
at the command line.
要修复这个问题,请将以下代码添加到pom文件中。记得要做一个Maven→更新项目…后来或mvn清洁在命令行编译。
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
#3
28
I know this is an old topic. I had the same problem. I tested all the answers about this topic. And nothing worked here... but i found another solution.
我知道这是个老话题。我也有同样的问题。我测试了关于这个话题的所有答案。而不是在这里工作…但我找到了另一个解决办法。
Go to pom->overview and add these to you properties:
转到pom->总览,并添加这些属性:
- Name: "maven.compiler.target" Value: "1.7"
- 名称:“maven.compiler.target”价值:“1.7”
and
和
- Name: "maven.compiler.source" Value: "1.7"
- 名称:“maven.compiler.source”价值:“1.7”
Now do a maven update.
现在进行maven更新。
#4
9
For imported maven project and JDK 1.7 do the following:
对于导入的maven项目和JDK 1.7,请执行以下操作:
- Delete project from Eclipse (keep files)
- 从Eclipse中删除项目(保存文件)
- Delete .settings directory, .project and .classpath files inside your project directory.
- 删除项目目录中的.settings目录、.project和.classpath文件。
-
Modify your pom.xml file, add following properties (make sure following settings are not overridden by explicit maven-compiler-plugin definition in your POM)
修改您的砰的一声。xml文件,添加以下属性(确保POM中显式maven-compiler-plugin -plugin定义不覆盖以下设置)
<properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties>
-
Import updated project into Eclipse.
将更新的项目导入Eclipse。
#5
5
I'm using Juno 4.2 with latest spring, maven plugin and JDK1.6.0_25.
我正在使用Juno 4.2与最新的spring、maven插件和JDK1.6.0_25。
I faced same issue and here is my fix that make default after each Eclipse restart:
我遇到了同样的问题,以下是我在每次Eclipse重启后默认的修复:
- List item
- 列表项
- Right-click on the maven project
- 右键单击maven项目
- Java Build Path
- Java构建路径
- Libraries tab
- 库选项卡
- Select current wrong JRE item
- 选择当前错误的JRE项
- Click Edit
- 点击编辑
- Select the last option (Workspace default JRE (jdk1.6.0_25)
- 选择最后一个选项(工作区默认JRE (jdk1.6.0_25)
#6
1
I was facing the same issue. In pom.xml I have specified maven compiler plugin to pick 1.7 as source and target. Even then when I would import the git project in eclipse it would pick 1.5 as compile version for the project. To be noted that the eclipse has installed runtime set to JDK 1.8
我也面临着同样的问题。砰的一声。我指定了maven编译器插件来选择1.7作为源和目标。即使这样,当我在eclipse中导入git项目时,它也会选择1.5作为项目的编译版本。需要注意的是,eclipse已经将运行时设置为JDK 1.8
I also checked that none of the .classpath .impl or .project file is checked in git repository.
我还检查了git仓库中没有检查.classpath .impl或.project文件。
Solution that worked for me: I simply deleted .classpath files and did a 'maven-update project'. .classpath file was regenerated and it picked up 1.7 as compile version from pom file.
对我有用的解决方案:我简单地删除了.classpath文件,做了一个“maven-update project”。
#7
1
If you are getting following type of error
如果你有以下类型的错误
Then do the following steps-->>
然后执行以下步骤——>>
- Go to Windows. Then select Preferences, in Which select java(on the left corner).
- 去窗口。然后选择Preferences,在其中选择java(在左上角)。
- In java select Installed JREs and check your JRE(if you have correctly installed jdk and defined environment variables correct then you will see the current version of the installed java here)as shown -
- 在java中选择install JREs并检查您的JRE(如果您正确安装了jdk和定义的环境变量,那么您将在这里看到安装的java的当前版本)
(I have Java 8 installed) Check the check box if it is not checked. Click apply and close.
(我已经安装了Java 8)如果没有选中,请选中复选框。单击apply和关闭。
Now Press Alt+Enter to go into project properties,or go via right clicking on project and select Properties.
现在按Alt+Enter进入项目属性,或者通过右键单击项目并选择properties。
In Properties select Java Build Path on left corner
在属性中,在左边选择Java构建路径
Select Libraries
选择库
And click edit(after selecting The JRE System Library...) In edit Click and select Workspace default JRE. Then click Finish
并单击edit(在选择JRE系统库之后…)在编辑单击并选择Workspace default JRE。然后单击Finish
In Order and Export Check the JRE System Library.
按顺序导出JRE系统库。
Then Finally Apply and close Clean the project and then build it.
最后应用并关闭项目,然后构建它。
Problem Solved..Cheers!!
问题解决了,干杯! !
#8
0
When creating a maven project in eclipse, the build path is set to JDK 1.5 regardless of settings, which is probably a bug in new project or m2e.
在eclipse中创建maven项目时,无论设置如何,构建路径都被设置为JDK 1.5,这可能是新项目或m2e中的一个bug。
#9
-1
I got an error in Eclipse Mars version as "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
我在Eclipse Mars版本中有一个错误,因为“构建路径指定执行环境J2SE-1.5”。工作区中没有安装与此环境完全兼容的JREs。
To resolve this issue, please do the following steps, "Right click on Project Choose Build path Choose Configure Build path Choose Libraries tab Select JRE System Library and click on Edit button Choose workspace default JRE and Finish
要解决这个问题,请执行以下步骤:“右键单击项目选择构建路径选择配置构建路径选择库选项卡选择JRE系统库,单击编辑按钮选择工作区默认JRE和Finish
Problem will be resolved.
问题将被解决。