IntelliJ IDEA 13 uses Java 1.5 despite setting to 1.7

后端 未结 13 859
我在风中等你
我在风中等你 2020-12-04 07:40

Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK), the following error is produced by

相关标签:
13条回答
  • 2020-12-04 08:32

    I tried making changes to Intellij IDEA as below:

    1.

    File >> Settings >> Build, Execution, Deployment >> Compiler >> Java Compiler >> project bytecode version: 1.8 >> Per-module bytecode version: 1.8
    

    2.

    File >> Project Structure >> Project Settings >> Project >> SDK : 1.8, Project Language : 8 - Lambdas
    File >> Project Structure >> Project Settings >> Modules >> abc : Language level: 8 - Lambdas
    

    but nothing worked, it reverted the versions to java 1.5 as soon as I saved it.

    However, adding below lines to root(project level) pom.xml worked me to resolve above issue: (both of the options worked for me)

    Option 1:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    

    Option 2:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题