Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Error " annotations are not supported....."

This is one of the most annoying errors ? What I can understand is that I am using a lower version of Java for compiling. How can I specify java version for maven ?

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project springAopMavenDemo: Compilation failure D:\JAVA Stuffs\projects\springAopMavenDemo\src\main\java\service\EmployeeServiceImpl.java:[13,1] annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations) @Service -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I really appreciate any help......I am using NetBeans 7.0 and Maven 3

like image 514
Amit Avatar asked Jan 28 '26 12:01

Amit


2 Answers

You need to tell maven which version of java the source should be compiled to

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

http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

like image 127
emeraldjava Avatar answered Jan 31 '26 00:01

emeraldjava


You are using some annotated code in your java, but compiling in your ide is using source java 1.3 by passing an additional commandline parameter most likely I had the same thing in intellij a while back

In netbeans config (sorry I am not a netbeans person) find where jdk/compiler setup is and change the command line arg

Update: quick net serach says it may be under Properties > Build > Compiling

like image 34
Shaun Hare Avatar answered Jan 31 '26 01:01

Shaun Hare