How to specify the jdk version in maven and jdk version in maven

Source: Internet
Author: User

How to specify the jdk version in maven and jdk version in maven
Problem reproduction:

When we create a maven project, the default jdk version is 1.5, and we usually install a version later than 1.7 on the machine. The jdk version is different. This problem occurs, there are two solutions:

It is not recommended to set the jdk version by right-clicking, because the updated project of this right-clicking setting is changed back to the original jdk version. It means being busy ....

Solution: solution 1: (one configuration, permanent use, recommended)

Copy the path to settings. xml and add the following code between <profiles> </profiles>. :

        <profile>                <id>jdk-1.8</id>                 <activation>                      <activeByDefault>true</activeByDefault>                      <jdk>1.8</jdk>                  </activation>            <properties>            <maven.compiler.source>1.8</maven.compiler.source>            <maven.compiler.target>1.8</maven.compiler.target>            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>            </properties>            </profile>
Second: (local configuration)

Add the following code to the project pom. xml file:

<Build> <plugins> <! -- Specify jdk 1.8 --> <plugin> <groupId> org. apache. maven. plugins </groupId> <artifactId> maven-compiler-plugin </artifactId> <version> 3.7.0 </version> <configuration> <source> 1.8 </source> <target> 1.8 </target> </configuration> </plugin> </plugins>

</Build>

 

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.