How to set default Maven's Java in Eclipse?

Suzan Cioc picture Suzan Cioc · Sep 30, 2013 · Viewed 14.3k times · Source

If I create new Maven project in Eclipse and base it on quickstart archetype, it appears with J2SE-1.5 in Java Build Path window and 1.5 in Java Compiler / JDK Compliance window.

So, I usually have to change this to other Java manually.

Where are these default setting come from?

How to change to 1.6 or 1.7?

Answer

Nicolas picture Nicolas · Sep 30, 2013

The m2eclipse plugin uses the settings from the POM. So you need to add this to your POM:

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