Maven : generics are not supported in -source 1.3

Problem

Maven as project build tool. Using Java generic function, when build with Maven, get this error message


generics are not supported in -source 1.3 (use -source 5 or higher to enable generics)

Solution

You need to tell Maven to use JDK 1.5 to compile your source code explicitly. Declare Maven compiler plugin (maven-compiler-plugin) in your pom.xml file, like this :

File : pom.xml


<project ...>
  <dependencies>
   ...
  </dependencies>
  <build>
    <plugins>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.3.1</version>
           <configuration>
               <source>1.5</source>
               <target>1.5</target>
           </configuration>
       </plugin>
    </plugins>
  </build>
</project>

3 comments on “Maven : generics are not supported in -source 1.3

  1. hello!,I really like your writing very much! proportion we be
    in contact more approximately your post on
    AOL? I need an expert on this area to unravel my problem.
    Maybe that is you! Taking a look ahead to see you.

    Reply
  2. Have you ever considered writing an ebook or guest authoring on other websites?
    I have a blog centered on the same information you discuss and would really like to have you share
    some stories/information. I know my viewers would appreciate your
    work. If you’re even remotely interested, feel free to shoot me an e mail.

    Reply
  3. Thanks very much it worked. I would never figure it out by myself. 🙂

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *