Maven modifies the default JDK version and the specified project JDK version

Source: Internet
Author: User

The problem is that I haven't done any setup since I installed Maven, I got Error:generics is not supported In-source 1.3 and Error:for-each loops when I use command mvn install n OT supported In-source 1.3, the first feeling is that there is a problem with the JDK (the cause of the error is obviously compiled with JDK1.3), but the project's JDK is set to 1.7, and the language is 7.0.

Here are two options (global settings and single-project settings) to solve the problem.

1. The global setting is to modify the MAVEN configuration file, you should first find your MAVEN installation directory, I use Linux, mvn-v can know path.

Under the Conf folder, locate the settings.xml under the Profiles node to add:

<profile> <id>jdk-1.7</id> <activation> <activebydefault>true</activebydefau lt> <jdk>1.7</jdk> </activation> <properties> <maven.compiler.source> 1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <MAVEN.C Ompiler.compilerversion>1.7</maven.compiler.compilerversion> </properties></profile>

OK, here is the 1.7 configuration, you can change to any version you need.

2. Project setup is to add plugin to your MAVEN project's Pom.xml file.

<build>        <plugins>             <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId> maven-compiler-plugin</artifactid>                 <version>3.1</version>                 <configuration>                     <source>1.7 </source>                     <target>1.7</target>                     <encoding>UTF-8</encoding>                 </configuration>             </plugin>        </ Plugins>    </build>

This project MAVEN will use 1.7 to compile.


Maven modifies the default JDK version and the specified project JDK version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.