I use IntelliJ IDEA as my development environment, and Maven for dependency management. I frequently build my project structure (directories, poms, etc) outside of IDEA and then import the project into IDEA using Import project from external model. This works great, except that in my poms I specify that the maven-compiler-plugin should use JDK 1.6, and when I import, IDEA informs me that the Language Level Changed and that Language level changes will take effect on project reload, and then prompts to reload the project. This is annoying because I always use the same JDK version.

我如何改变IntelliJ IDEA使用的默认JDK,以便我不必每次导入新项目时都重新加载我的项目?


当前回答

我正在使用IntelliJ 2020.3.1和文件>其他设置…菜单选项消失。我以通常的方式进入设置,搜索“jdk”。在构建,执行,部署>构建工具> Maven >导入下,我找到了将解决我的具体问题的设置:

用于导入器的JDK。

其他回答

上面的回答非常有用,但在所有设置之后,项目运行的版本是错误的。最后,我注意到它也可以在Dependencies窗口中配置。 2018.1.3文件->项目结构->模块->来源和依赖项。

我发现在最近的IntelliJ版本中,IDEA需要Java 1.8,但默认情况下没有配置。

我们可以从项目设置>项目>项目SDK更改路径或配置

在这里我们可以编辑或添加JDK的路径。

(在我的例子中,路径位于C:\Program Files\Java\ jdk1.8.0_102)

对于最新版本的intellij,为新项目设置默认jdk/sdk请转到

配置->结构的新项目->项目设置->项目SDK

要自己修改Intellij-IDE的JDK版本:

启动IDE -> Help -> Find Action

比类型:

Switch Boot JDK

或者(取决于你的版本)

Switch IDE boot JDK

在我的linux机器上,我使用这样的脚本:

export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh