The Maven engineering POM defines the JDK version

Source: Internet
Author: User

Today, I took the previous project into eclipse and found the error, some classes are not supported in 1.6, you need to set the JDK version to 1.7, I make changes directly through the prompts in Eclipse, and then update Project, The discovery is back to the SE1.6 version, I think it must be in the POM definition of this Java version, look at the pom file, found the compilation plug-in definition of version 1.6, code:

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
   <source>1.6</source>
   <target>1.6</target>
</configuration>
</ Plugin>

So it would be nice to change the compiled version to 1.7.

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</ Plugin>

Note: Here is a compilation of plug-ins through the project

Also, define the JDK version of the current project in a general project

   <properties>
         <...> ...<...>
        <java.version>1.8</java.version> ...
        . > ...<...>
    </properties>

This properties property configuration is typically configured after the <parent> tag, and if you refer to your company's framework, you should have a defined version within the framework that you don't need to introduce, and, in short, set as needed. The settings can then be introduced in the compilation plug-in:

<plugin>  
<artifactId>maven-compiler-plugin</artifactId>  
<configuration>  
<source>${java.version}</source>  
<target>${java.version}</target>  
</ Configuration>  
</plugin>  


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.