最近从github上fork了张开涛的Shiro代码,IDE是Intellij IDEA。发现无论是Project还是Module,默认的Language Level都是JDK 1.5,而且每次修改都仅限于当前有效,稍后又会变回JDK 1.5

搜索了一番,解决办法都是这pom.xml中指定compiler的版本,如下:

<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>

还有简洁版本:

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

至于原因,则是maven compiler plugin自身问题:

Apache Maven Compiler Plugin

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. 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.

上面这一段的内容是:

  该插件从3.0版本开始,默认编译器是javax.tools.JavaCompiler (前提是JDK 1.6以后);如果想使用javac,需要手动设置。

  当前(Version: 3.5.1),默认使用JDK 1.5解析和编译源码,与运行Maven的JDK版本无关!!!如果想修改,见链接。

ps,链接中的内容如下:

    <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>

参考:

  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 的Language Level的问题的更多相关文章

  1. [转]IDEA 出现编译错误 Multi-catches are not supported a this language level 解决方法

    转自 http://blog.csdn.net/qq465235530/article/details/53897538 首先出现这种问题是说明正在使用低版本jdk编译其本身不支持的语法,出现这种情况 ...

  2. language level in Intellij IDEA

    The Language level setting sets which features the code assistance in the editor should support. For ...

  3. intellij idea jdk language level

    jdk的新的版本会兼容旧的版本. 如果安装了新的jdk,但是还是希望使用旧版本的特性,这个可以使用jdk language level来实现. 比如安装了jdk8,但是希望用7,那么language ...

  4. idea中的language level 介绍

    language level 介绍 其他 IDE 没有看到类似 language level 的设置,所以这个功能应该算是 IntelliJ IDEA 特有的,可是 IntelliJ IDEA 官网也 ...

  5. idea language level 介绍

    language level 介绍 其他 IDE 没有看到类似 language level 的设置,所以这个功能应该算是 IntelliJ IDEA 特有的,可是 IntelliJ IDEA 官网也 ...

  6. 自动重置Language level 5 与 Java Complier 1.5

    Intellij IDEA用Maven来构建项目,若pom.xml没有指定版本,总是默认Language level 5 与 Java Compiler 1.5. 以下是两种修改方式: 1. 手动进行 ...

  7. idea开发工具下报Set language level to 6-@Override in interfaces的解决方法

    idea开发工具下报Set language level to 6-@Override in interfaces的解决方法 实现接口时报如下错误:Set language level to 6-@O ...

  8. diamond types are not supported at this language level

    在intellij导入git项目之后出现 diamond types are not supported at this language level错误 或者String等报错 File->P ...

  9. idea报错Diamond types are not supported at this language level

    project structure中的project ,SDK选择1.8,Project language level选择8 project structure中的module,选择Language ...

随机推荐

  1. python标准库介绍——7 cmath 模块详解

    [Example 1-61 #eg-1-61] 所展示的 ``cmath`` 模块包含了一些用于复数运算的函数. ====Example 1-61. 使用 cmath 模块====[eg-1-61] ...

  2. OPENGL NEHE Lesson11 11课的计算公式推导

    计算多边形公式推导: 条件x 离散的值从0到45; y离散的值从0到45; z是符合正弦波. 问题: 1 要求x’=f(x)映射到 x’ ∈[-4.5, 4.5], x ∈{0, 1, 2, …, 4 ...

  3. ORACLE生成唯一标识函数

    -- Create tablecreate table TAB_TEST( id VARCHAR2(40) not null, fxnum VARCHAR2(40)) ---------------- ...

  4. Unity3d官方测试插件学习-单元测试,集成测试

    2016/11/27更新:官方的测试工具有许多问题,我修改了一个版本 https://git.oschina.net/Hont/UnitTest_Modifyed 支持切场景,异常不失败等 其实Uni ...

  5. 教你轻松自己定义ViewPagerIndicator

    ViewPagerIndicator集成分页指示器.事实上就是标题栏和ViewPager的联动效果,大家先看一下效果图直观了解:(图侵删) 这篇文章将会教大家怎么简单高速地制作自己的ViewPager ...

  6. application , application pool., W3wp ,httpapplication, domain

    Hosting and Consuming WCF Services https://msdn.microsoft.com/en-us/library/bb332338.aspx http://www ...

  7. linux命令(33):less

    一.less指令 less 工具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性. 在 more 的时候,我 ...

  8. javascript 触发器

    <script type="text/javascript"> function time_logs() { var time = new Date(); var ho ...

  9. Java类型Float&&Double

    package study; public class testFloatDouble { public static void main(String[] args) { float f = 0; ...

  10. LeetCode: Generate Parentheses 解题报告

    Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of w ...