zjor
zjor

Reputation: 1043

Maven complains about @Override annotation first time but compiles successfully next time

I run command like this:

mvn tomcat:redeploy 

as see a lot of errors like "...of type ImageDaoImpl must override a superclass method"

But after this I do nothing, just run this command again and this time it compiles ok! Could anyone tell me how to fix that? Every odd compilation time I get this error, it's quite annoying..

Upvotes: 2

Views: 3754

Answers (2)

zjor
zjor

Reputation: 1043

I've just resolved my issue) I have two plugins:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <configuration>
        <source>1.5</source>
        <complianceLevel>1.5</complianceLevel>
    </configuration>
...
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>${jdk.version}</source>
        <target>${jdk.version}</target>
    </configuration>
</plugin>

The first plugin was configured for 1.5 java the other was configured by ${jdk.version} which is 1.6 It's still a mystery for me why it compiles at all, but after setting 1.5 to 1.6 my issue has gone.

Upvotes: 1

RonU
RonU

Reputation: 5795

I can't immediately tell you why the issue goes away, but typically this compiler error indicates that you're attempting to compile Java 6-compliant code (which allows @Override on implementations of interfaces) with a compiler set to Java 5 compliance (which only allows @Override when overriding a concrete method from a super class).

Upvotes: 2

Related Questions