IDEA: javac: source release 1.7 requires target release 1.7

后端 未结 18 1110
青春惊慌失措
青春惊慌失措 2020-11-22 06:26

When running a JUnit test, using IntelliJ IDEA, I get

\"enter

How can I correc

相关标签:
18条回答
  • 2020-11-22 07:07

    Make sure right depency is selected. File > Project Structure

    Select your project and navigate to Dependencies tab. Select right dependancy from dropdown or create new.

    0 讨论(0)
  • 2020-11-22 07:09

    In IntelliJ IDEA 14.1 the "Target bytecode version" is in a different place.

    The following change worked for me:

    File > Settings... > Build, Execution, Deployment > Compiler > Java Compiler : change Target bytecode version from 1.5 to 1.8

    enter image description here

    enter image description here

    0 讨论(0)
  • 2020-11-22 07:09

    I found another way to run into this error. You can get this if you have been re-organizing your directory structure, and one of your poms is pointing to the old parent which no-longer configures javac (because that configuration was moved to a middle level). If this happens the top level defaults to 1.5 and the misbehaving lower level pom inherits it.

    So another thing to check when you see this error is that your pom structure is matching your directory structure properly.

    0 讨论(0)
  • 2020-11-22 07:10

    From one moment to the other I also got this error without a clear reason. I changed all kinds of settings on the compiler/module etc. But in the end I just recreated the IntelliJ project by reimporting the Maven project and the issue was solved. I think this is a bug.

    IntelliJ 12 129.961

    0 讨论(0)
  • 2020-11-22 07:14

    Have you looked at your build configuration it should like that if you use maven 3 and JDK 7

    <build>
        <finalName>SpringApp</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
    
    0 讨论(0)
  • 2020-11-22 07:15

    I resolved it by setting the field blank:

    Settings > Compiler > Java Compiler > Project bytecode version

    Than IntelliJ uses the JDK default version.

    0 讨论(0)
提交回复
热议问题