Why is Maven generating this error: "...is not supported in -source 1.5"?

The default source/target levels are 1.5, which doesn't support Java 1.7 syntax, obviously.

  • http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#source
  • http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#target

As to why it would "suddenly" change, something changed in your m2e or project configuration.


Most likely this is a problem with your environment, not maven (ie, your JAVA_HOME environmental variable changed). It's worth noting that the compiler plugin is required anyway. By including this compiler section in your pom you are ensuring that your code gets compiled with the correct compiler, regardless of your environmental settings.

Tags:

Java

Maven