IDEA: javac: source release 1.7 requires target release 1.7

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

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

\"enter

How can I correc

18条回答
  •  遥遥无期
    2020-11-22 06:59

    Most likely you have incorrect compiler options imported from Maven here:

    compiler options

    Also check project and module bytecode (target) version settings outlined on the screenshot.

    Other places where the source language level is configured:

    • Project Structure | Project

    • Project Structure | Modules (check every module) | Sources

    Maven default language level is 1.5 (5.0), you will see this version as the Module language level on the screenshot above.

    This can be changed using maven-compiler-plugin configuration inside pom.xml:

    
      [...]
      
        [...]
        
          
            org.apache.maven.plugins
            maven-compiler-plugin
            
              1.8
              1.8
            
          
        
        [...]
      
      [...]
    
    

    or

    
      [...]
      
        1.8
        1.8
      
      [...]
    
    

    IntelliJ IDEA will respect this setting after you Reimport the Maven project in the Maven Projects tool window:

提交回复
热议问题