Suzan Cioc
Suzan Cioc

Reputation: 30097

Eclipse disliked @Override annotation

After I have created my project from scratch, played with maven dependency control and copied all my old files to a new project, I found that Eclipse now sweared on @Override annotations. It says that "method must override superclass method" when this annotation present and stays cool if not. Also it does not autoinsert this annotation when using quick input.

Why this can be?

Upvotes: 2

Views: 406

Answers (2)

Philipp Reichart
Philipp Reichart

Reputation: 20961

You most likely (want to) put @Override on a method inherited from an interface. This is only valid since Java 1.6, your Eclipse project is most likely set to source level 1.5 (alternatively you're running a very outdated 1.5 JDK, but that's unlikely)

Upvotes: 1

Andrew T Finnell
Andrew T Finnell

Reputation: 13628

Change your maven pom to enforce Java 6 or 7. I've had this problem before where if you import a project with a pom, it defaults to Java 1.5 JDK.

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

Upvotes: 3

Related Questions