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。

其他回答

我使用的是IntelliJ IDEA 14.0.3,我也有同样的问题。选择菜单文件\其他设置\默认项目结构…



选择项目选项卡,部分项目语言级别,从下拉列表中选择级别,此设置为所有新项目的默认设置。

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

用于导入器的JDK。

下载并解压一个JDK存档文件(.tar.gz),并将其作为SDK添加到“项目结构”对话框中(Ctrl+Alt+Shift+S)

点击动图放大

还要确保设置适当的“项目语言级别”。我在创建动图的时候忘记了。

>项目>项目语言级别

对于Java 8,设置为8,对于Java 9,设置为9,依此类推。

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

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

启动IDE -> Help -> Find Action

比类型:

Switch Boot JDK

或者(取决于你的版本)

Switch IDE boot JDK