arundhaj

all that is technology

How to set source level in Maven projects

 

During developement... compiling or testing a maven project might lead to

error: generics are not supported in -source 1.3

Maven uses the 1.3 source setting as default, however it can be solved by explicitly mentioning the source level in project's pom.xml file.

<build>
 <plugins>
  <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.5.1</version>
   <configuration>
    <source>1.7</source>
    <target>1.7</target>
   </configuration>
  </plugin>
 </plugins>
</build>

However be reminded that setting the source level explicitly would solve the compile errors, but not having the appropriate runtime would lead to runtime errors.

Comments