简体   繁体   中英

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. 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. Specifically, I (believe I) have configured my Default Settings for 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:

在此处输入图片说明

The resulting project structure still defaults to using 1.5 as the language level for modules:

在此处输入图片说明

Even though the project picked up on the 1.8 setting:

在此处输入图片说明

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.)

TIA!

This is not what I'd hoped for, but it seems that this is an interaction with 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).

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. After all, when I went through the "new maven project" wizard, I told it that I wanted a Java 8 project. Would it be terribly difficult to tweek the pom to suit.

Check one point to NetBeans in this case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM