Intellij idea Module's language level problem

Source: Internet
Author: User
Tags maven compiler plugin

Zhang Kaitao's Shiro code was recently forked from GitHub, and the IDE is IntelliJ idea. The default language level is JDK 1.5 for both project and module, and each modification is limited to the current one and will later be changed back to JDK 1.5.

Search, the solution is the compiler version specified in this pom.xml, as follows:

<Build>    <Plugins>        <plugin>            <groupId>Org.apache.maven.plugins</groupId>            <Artifactid>Maven-compiler-plugin</Artifactid>            <version>2.3.2</version>            <Configuration>                <Source>1.8</Source>                <Target>1.8</Target>            </Configuration>        </plugin>    </Plugins></Build>

There is also a concise version:

< Properties >  < Maven.compiler.source >1.8</maven.compiler.source>  <  Maven.compiler.target>1.8</maven.compiler.target> </ Properties >

The reason for this is the MAVEN compiler plugin own problem:

Apache Maven Compiler Plugin Javax.tools.JavaCompiler The default source setting is 1.5 and the default target setting is 1.5 independently of the JDK you run Mavenwith. If you want to change these defaults, you should set source and target as described in Setting the-source and-target of The Java Compiler.

The content of the above paragraph is:

The plugin starts with version 3.0, the default compiler is Javax.tools.JavaCompiler (provided that JDK 1.6 is available), and you need to set it manually if you want to use Javac.

Currently (version:3.5.1), using JDK 1.5 to parse and compile the source by default , regardless of the JDK version running MAVEN !!! If you want to change, see the link.

PS, the contents of the link are as follows:

    <Project>      [...] <Build>        [...] <Plugins>          <plugin>            <groupId>Org.apache.maven.plugins</groupId>            <Artifactid>Maven-compiler-plugin</Artifactid>            <version>3.5.1</version>            <Configuration>              <Source>1.8</Source>              <Target>1.8</Target>            </Configuration>          </plugin>        </Plugins>        [...] </Build>      [...] </Project>

Reference:

http://stackoverflow.com/questions/27037657/stop-intellij-idea-to-switch-java-language-level-everytime-the-pom-is-reloaded

Http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

Http://docs.oracle.com/javase/8/docs/api/javax/tools/JavaCompiler.html

Intellij idea Module's language level problem

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.