Maven and the “method does not override a method from its superclass” error

Spent more time than I care to admit today stuck on something soooo simple. Was trying to build a maven project at home, and kept getting this error: “method does not override a method from its superclass”.

What is happening? Well, there is a @Override annotation on one of the methods, but it doesn’t have a superclass–it is annotating a method that is being implemented (from an interface), not a method that is inherited (from a superclass).

The @Override annotation is a Java 1.5 feature, and the error message I was getting was coming (correctly) from a 1.5 compiler. However in Java 1.6 the @Override annotation can also be applied to methods that are implemented from an interface.

Someone started using Java 6 and Java 6 features in the project, without updating the pom.xml file to fix this. Grrr.

The fix was to update the configuration of the maven-compiler-plugin to use 1.6 as both the source and the target, rather than 1.5. set my JAVA_HOME to point to Java 1.6 and that was that. I wound up putting the config for maven-compiler-plugin back to 1.5. Which doesnt seem quite right, either, but fixes the UTF-8 error I am getting. Ugh!