views:

132

answers:

3

I have a maven website project generated by archtype plugin with eclipse IDE. The problem is when i need to use generics or any thing of java 5 or 6, i changed the project compiler to 1.6 and i got a error mark on the project icon in the package explorer but everything is fine. I think it is cause by maven but I dont know how to get rid of it.

Thank you

A: 

You need to make sure Eclipse is compiling with the Java 1.6.

Go to your project-specific settings: Project > Properties. Type "Java Compiler" in the text box to the left.

Ensure that all those drop-downs under "JDK Compliance" are set to 1.6. Otherwise check the box to 'Enable project-specific settings' and manually set them to JDK 1.6.

You may also want to enforce this through Windows > Properties, Java > Compiler, Compiler compliance level > 1.6, for global default settings.

Also make sure that the version of the JDK on your build path is the one you want. Hope this helps.

Cuga
+3  A: 

Don't forget to configure the maven-compiler-plugin:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <!-- Lock down plugin version for build reproducibility -->
    <version>2.0.2</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>
Pascal Thivent
Yeah maven defaults to Java 1.4 if you don't specify the version you want to target.
Patrick
A: 

This is kludgy, but I've run into similar issues and worked around them by deleting the project (and not the sources obviously). Then I would import the maven project into my workspace.

m2eclipse ends up resolving the project again and sets up the project correctly.

Mike Cornell