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

Is this one of the most annoying mistakes? I can understand that I am using a lower version of Java to compile. How to specify java version for maven?

Failed to fulfill the goal org.apache.maven.plugins: Maven-compiler-plugin: 2.0.2: compile (by default compilation) for the 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 (to enable annotations use source 5 or higher) @Service → [Help 1]

To see the full trace of the error stack, restart Maven with the -e switch. Restart Maven with -X to enable full debug logging.

For more error information 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

+3
source share
3 answers

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

<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

+6
source

You use some annotated code in java, but the compilation in your idea uses the original java 1.3, passing an additional command line parameter, most likely I had the same thing in intellij some time ago

netbeans (, netbeans) , ​​jdk/, arg

: , "" > "" > ""

+1

emeraldjava . :

Maven:

<build>
    ...
    <maven.compiler.source>1.5</maven.compiler.source>
    <maven.compiler.target>1.5</maven.compiler.target>

-, Maven- (, 2.3.2), 1,5, :

The compiler plugin is used to compile the sources of your project. The default compiler is javac and is used to compile Java sources. Also note that currently the default source value is 1.5 and the default target is 1.5, regardless of the JDK you run Maven with.

( source )

+1
source

All Articles