stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level)

前端 未结 9 1142
悲&欢浪女
悲&欢浪女 2020-11-28 01:59

Using IntelliJ 12, I have a java project and I use maven with a pom.xml. My project is using java8, but it seems the default project language level has been set to 6 while i

9条回答
  •  情话喂你
    2020-11-28 02:41

    I think this has to do with a conceptual conflict between the Maven compiler plugin and IntelliJ idea. Apparently the newer versions of the compiler plugin have a default level of 1.5 (see http://maven.apache.org/plugins/maven-compiler-plugin/). So if the compiler plugin is used at all in a project, and the compiler level is not explicitly set in the pom.xml, whenever the POM is re-processed the level will revert to the default.

    So there is a conceptual conflict which is ignored by Intellij IDEA. The IDE still allows one to set the project and module settings, but provides no warning or feedback that this setting is controlled by pom.xml. Solutions would either be to explicitly allow overriding the POM compiler plugin setting (perhaps not wise because what then happens when you use maven on the command line), or to deactivate the controls in the IDE when this setting from the POM is in effect.

    The solution at the present time is to set the desired compiler level in the compiler plugin in the pom, the re-import, rather than trying to set it in module settings.

提交回复
热议问题