When working in a Java environment with multiple developers using their own IDE preference I often get error like this opening a project with IntelliJ: “@Override is not allowed when implementing interface method”. Since I’m not a Java dev fulltime I tend to forget this stuff, so basically this is a reminder for myself …

Basically IntelliJ thinks the project is Java 1.5 by default so while my console / mvn build works perfectly due to using Java 8 the IDE thinks differently.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
  </configuration>
</plugin>

Project Language

File > Project Structure > Project > Language level

Module Language

If your project has multiple modules check that they inherit the project language, or when needed, set the correct non-default on the module

File > Project Structure > Module > Language level

or

Right Click module > Open Module Settings 


Java Compiler for Default Projects

While your at it, set this value as a default for new projects as well

File > Other Settiings > Default Settings > Build, Execution, Deployment > Compiler > Java Compiler > Project Bytecode version

 

Houd jij je kennis graag up to date?

Mis niets meer van onze kennisdocumenten, events, blogs en cases: ontvang als eerste het laatste nieuws in je inbox!

Fijn dat we je op de hoogte mogen houden!