Main Tutorials

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>

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
activate espn
4 years ago

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.

Shopping discount
10 years ago

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.

mih
11 years ago

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