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

前端 未结 9 1071
悲&欢浪女
悲&欢浪女 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:44

    As per Mark's comment, here is how to do it:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
  • 2020-11-28 02:45

    For me the solution of updating the POM (plugins plus properties) to the required Java compiler version (1_7 in my case) worked. However as the .iml file for each project was generated with original pom (with default compiler version of 1_5 as explained by someone above) has a JDK version of 1_5, this still overrides the pom version.

    I deleted the .idea folder manually and imported the module into IntelliJ with a reimport from the updated pom. When I reimported the Module from updated POM,I could see that the iml files had the updated JDK version (1_7 in my case) .

    0 讨论(0)
  • 2020-11-28 02:46

    A shorter version of vikingsteve's answer is:

    <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    0 讨论(0)
提交回复
热议问题