Saturday, March 23, 2013

Eclipse Maven Build Fail - use -source 5 or higher to enable annotations

When you are using Maven package option in eclipse for generating a war file of a java web project which has the annotation in it,you will encounter the Build Fail error, below is the sample error which you will encounter, if the JRE and Annotation compiler wasn't configured properly in Eclipse
FAILED for project: 
    ExpenseReporting:ExpenseReporting:war:0.0.1-SNAPSHOT
Reason:
C:\Documents and Settings\MRamanujam\workspace\ExpenseReporting\src\main\java\com\expense\domain\Base.java:[9,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
 @Id
To resolve the issue first you need to make sure that, Java compiler version you are using is greater than 5

javac -version

Next go to your project properties, select the Java Compiler in the tree menu.

Make sure the Compiler Compliance level is more than 1.5

Next click Annotation Processing and enable project specific settings, and apply the settings.


Then do the Maven package, your build will be successful, and the war wil be generated.

Happy Programming...!!!

No comments:

Post a Comment