@Override is not allowed when implementing interface method

前端 未结 7 1400
难免孤独
难免孤独 2021-01-30 00:49

I have the problem mentioned in the title. You could say that this thread duplicates another one: How do I turn off error validation for annotations in IntelliJ IDEA?

Bu

相关标签:
7条回答
  • 2021-01-30 01:15

    In JIdea 2020.1.2 and above,

    1. Go to Project Structure [ Ctrl+Alt+Shift+S ]
    2. Select Modules sub section
    3. Select each module
    4. Under sources-section, check Language Level
    5. Change the Language Level as required

    NOTE:

    If you get below error after this change,

    Error:java: Compilation failed: internal java compiler error
    

    You have to change the target bytecode version as well.

    1. Go to Settings [ Ctrl+Alt+S ]
    2. Select Java Compiler
    3. Select module in the table
    4. Change the byte-code version to map what you selected in the previous step for language-level

    0 讨论(0)
  • 2021-01-30 01:16

    I ran into this problem for the first time while using a multi module maven project. As other answers / IDE suggested, we need to set the language level.

    Rather than changing the setting of IDE, to make the project IDE agnostic, I update the parent pom with below properties, which solved the issue.

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    0 讨论(0)
  • 2021-01-30 01:18

    If you are using maven, add maven compiler plugin to the project's pom.xml file.

    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    This solved the issue for me.

    0 讨论(0)
  • 2021-01-30 01:19

    If your project has multiple modules, also check that every module uses language level 6 or above, or use the project's language level (see Project Settings > Modules > xxx > Language level).

    You may need to reload your project once it is modified.

    0 讨论(0)
  • 2021-01-30 01:19

    At your module/project, Right click to see context menu:

    enter image description here

    Choose Open Module Settings or press F4. In setting windows:

    enter image description here
    Set value for Choose Language level section.


    You also should check Project language level by this way: press Ctrl+Alt+Shift+S

    enter image description here

    0 讨论(0)
  • 2021-01-30 01:20

    There's also a language level for every module. Please check your module settings in the Project Structure.

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