Andrei Roșu-Cojocaru Andrei Roșu-Cojocaru - 1 year ago 121
Java Question

Configuring Maven in Eclipse to work with Java source level 7

I have the following problem while trying to execute the compile goal on an Eclipse Java project with Maven:


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ...: Compilation failure

[ERROR] multi-catch statement is not supported in -source 1.5

[ERROR] (use -source 7 or higher to enable multi-catch statement)


The JDK in the Eclipse project is configured to use version 1.8.0_60.

The compiler compliance level is also set to 1.8: http://imgur.com/4AvjZd6

However, the settings above are related to the Eclipse project configuration and not to Maven settings.

In Window -> Preferences, I have seen the compiler plugin is also set to 1.8: http://imgur.com/BpNANqZ

The question is: how to I tell Maven to use source 1.7 (or above)?

Answer Source

Try adding the following to pom.xml

<properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
</properties>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download