Solution for maven issue generics are not supported in -source 1.3

When running a maven build you might sometimes get errors such as

"generics are not supported in -source 1.3"
or
"for-each loops are not supported in -source 1.3".
Read on for a solution.



When you attempt to use code in your java class that uses the later features such as Generics or for-each loops you might run into a weird error from maven. The error might read like:
generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)
or
for-each loops arenot supported in -source 1.3 (use -source 5 or higher to enable for-each loops)

This happens because you don't have an explicit maven-compiler-plugin configuration defined in your pom.xml. You can easily overcome this issue by adding the below configuration to the plugins section of your pom.xml file:

<plugin>
  <artifactid>maven-compiler-plugin</artifactid>
  <configuration>
    <compilerargument>-verbose</compilerargument>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

Hope that helps.