Maven default is using JDK1.3 for the compilation (mvn compile), when your Java code contains any annotation function, the following error message will prompt during the Maven build “annotations are not supported in -source 1.3

[INFO] Compilation failure
E:\workspace\serlvetdemo\src\main\java\com\mkyong\AppServletContextListener.java:
[8,2] annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations)
        @Override

Solution

The solution is very simple, just include the maven compiler plugin and specify the JDK version. Include the following Maven plugin information in “pom.xml” file

<project ....>
<build>
	  <plugins>
	  	<plugin>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.6</source>
				<target>1.6</target>
			</configuration>
		</plugin>
	   </plugins>
  </build>
</project>

Maven is using JDK 1.6 for all the compilation now.

Reference

http://maven.apache.org/plugins/maven-compiler-plugin/