[英]Module default language level in IntelliJ IDEA maven project?
EDIT: I've determined that my configuration works fine for IDEA format projects, but only fails in the curious way noted below for maven projects. 编辑:我已经确定我的配置对IDEA格式的项目工作正常,但是对于maven项目,它仅以下面提到的奇怪方式失败。 But since that's what I need, I'd really like to get this resolved :) 但这是我的需要,所以我真的很想解决这个问题:)
Please note, I do not think this is the duplicate that's been suggested. 请注意,我不认为这是重复的建议。 the referenced question describes how to change an individual project's configuration. 所引用的问题描述了如何更改单个项目的配置。 I can do that, but it's not what I want to do. 我可以做到,但这不是我想做的。 I want to change the default settings when a brand new project is created (note also, I said created , not imported, as one item in that referenced question discusses.) Please either explain how that (exceedingly long, and therefore hard to follow) question answers my specific question, or please remove the "duplicate" flag. 我想在创建一个全新项目时更改默认设置(另请注意,正如我提到的问题所讨论的那样,我说过创建而不是导入)。请要么说明如何做(过长,因此很难遵循)问题回答了我的特定问题,或者请删除“重复”标志。
I've checked many questions here that seem related, and the docs ( https://www.jetbrains.com/help/idea/working-with-sdks.html ) but I must be missing something, as things are not working as I interpret they should be. 我在这里检查了许多似乎相关的问题,并检查了文档( https://www.jetbrains.com/help/idea/working-with-sdks.html ),但我必须丢失一些内容,因为这些内容无法正常工作我认为它们应该是。 Specifically, I (believe I) have configured my Default Settings for Java 1.8: 具体来说,我(相信我)已经为Java 1.8配置了我的默认设置:
And similarly, my Default Project Structure: 同样,我的默认项目结构:
And according to the docs and that screenshot, this should set the language level default for all project modules. 根据文档和该屏幕截图,这应该为所有项目模块设置默认的语言级别。
However, if I create a new project (maven project, in case it makes any difference) and (by default) tell it to use 1.8: 但是,如果我创建一个新项目(maven项目,以防万一),并且(默认情况下)告诉它使用1.8:
The resulting project structure still defaults to using 1.5 as the language level for modules: 最终的项目结构仍默认使用1.5作为模块的语言级别:
Even though the project picked up on the 1.8 setting: 即使项目采用1.8设置:
Can anyone tell me what I missed? 谁能告诉我我错过了什么? (Please note that I create a lot of small projects for demonstration purposes, and if I have to configure this manually in every single case, that would really make me rethink my plan to migrate to IntelliJ.) (请注意,我出于演示目的创建了许多小型项目,如果必须在每种情况下手动配置此项目,那实际上会让我重新考虑迁移到IntelliJ的计划。)
TIA! TIA!
This is not what I'd hoped for, but it seems that this is an interaction with maven. 这不是我希望的,但是似乎这是与Maven的互动。 Because the pom generated for an "empty" maven project does not specify maven.compiler.source/target, the modules , but only the modules, of the project are forced to Java 5 (even though IntelliJ claims that the rest of the project is in some sense Java 8 or 9). 因为为“空” maven项目生成的pom没有指定maven.compiler.source / target,所以该项目的模块 ( 仅模块)被强制使用Java 5(即使IntelliJ声称该项目的其余部分是Java 5)。在某种意义上讲Java 8或9)。
I suppose this is "just the way the components interact" and most folks are building corporate projects with pre-existing pom files, but it seems like an oversight in the defaulting. 我认为这只是“组件交互的方式”,大多数人都在使用预先存在的pom文件构建公司项目,但这似乎是对默认设置的疏忽。 After all, when I went through the "new maven project" wizard, I told it that I wanted a Java 8 project. 毕竟,当我完成“新的Maven项目”向导时,我告诉我我想要一个Java 8项目。 Would it be terribly difficult to tweek the pom to suit. 使pom适应一周会非常困难。
Check one point to NetBeans in this case. 在这种情况下,请检查一下指向NetBeans的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.