IntelliJ、Maven 和 Java 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6947797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:59:30  来源:igfitidea点击:

IntelliJ, Maven and Java 7

javamaven-2intellij-ideajava-7

提问by Mike

So I opened an existing project in IntelliJ 10.5 as a maven project. I had first added the JDK 7 to my list of SDKs in order to try out the features. However for some reason my mvn commands would fail, so I switched the maven runner back to 1.6. But I'm getting a weird error where some maven commands are still being run with Java 7.

所以我在 IntelliJ 10.5 中打开了一个现有项目作为 maven 项目。我首先将 JDK 7 添加到我的 SDK 列表中,以便试用这些功能。但是由于某种原因,我的 mvn 命令会失败,所以我将 maven runner 切换回 1.6。但是我遇到了一个奇怪的错误,其中一些 Maven 命令仍在使用 Java 7 运行。

In the Maven Projects view when I right click on a lifecycle in the module and select Run Maven Build everything works correctly, however when I select Run " clean" it still uses the 1.7 JDK. I have removed the JDK 7 from my list and now I get an error saying it can't find JRE '1.7'.

在 Maven 项目视图中,当我右键单击模块中的生命周期并选择运行 Maven 构建一切正常时,但是当我选择运行“干净”时,它仍然使用 1.7 JDK。我已经从我的列表中删除了 JDK 7,现在我收到一条错误消息,说它找不到 JRE '1.7'。

I honestly have no idea how to fix this, but if anyone has any suggestions that would be great.

老实说,我不知道如何解决这个问题,但如果有人有任何建议,那就太好了。

回答by CrazyCoder

In the Maven Projectspanel press the Settingsbutton (or open Settings| Maven| Runner).

Maven Projects面板中按下Settings按钮(或打开Settings| Maven| Runner)。

Make sure that JREis set to the existing JRE configuration (1.6).

确保将JRE设置为现有的 JRE 配置 (1.6)。