最近从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. Linux 配置rdate时间服务器方法

    配置多台服务器时,经常需要让各个服务器之间的时间保持同步,如果服务器有外网环境,可以直接同外部的时间服务器更新时间,可以采用rdate命令更新时间: rdate -s tick.greyware.co ...

  2. python dataframe 在merge时 产生笛卡尔积

    在pandas中,concat, merge, join的使用方法可以参考以下资料: http://blog.csdn.net/stevenkwong/article/details/52528616 ...

  3. js 正则表达式 exec 和 match的使用

    match body.match(/\d\.\d\.\d\.\d:\d/g); // 推荐使用exec可以拿到多个数组 exec var a = [ 'PHPSESSID=sglvjui97o18bg ...

  4. MySQL使用伪列

    在查询数据库的时候,我们有时候需要对查询出来的数据加上序列,1,2,3,……n 例如:我们根据表的某个字段排序后,要对这些数据加上序列,这个时候序号常常不是我们建表时设置好的自增的主键id,怎么办呢? ...

  5. unity, 荧光效果(bloom)

    ----更新:2015-5-31 详细实现过程见:http://www.cnblogs.com/wantnon/p/4542172.html ----原帖:2015-4-16 用摄像机特效只能做全屏b ...

  6. wpf程序线程与UI内容交互

    在UI线程里执行复杂的操作,会造成UI假死.常用的解决方法是开2个线程. 而新线程要调用UI里的东西,必须这么用: this.Dispatcher.Invoke(content);

  7. Photoshop制作Android UI: 怎样将图片背景变为透明

    看烦了代码.今天玩玩PS吧.本人是PS小白.Android开发中不可避免的要做一些图片,但我发现居然没有相似的专门教程.真想拜个美工为师.还记得2012年去宁波实习时为了将图片缩小我还matlab写个 ...

  8. nyoj 715 Adjacent Bit Counts

    描述 For a string of n bits x1, x2, x3, …, xn,  the adjacent bit count of the string  is given by      ...

  9. ny2 括号配对问题

    括号配对问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 现在,有一行括号序列,请你检查这行括号是否配对.   输入 第一行输入一个数N(0<N<=1 ...

  10. NSIS安装程序制作工具判断系统是否安装.NET

    前段时间忙了很久的系统总算上线了,由于是WinForm程序不能整个文件夹的发给客户使用.所以必须要打包,记得以前在VS2005中是自带部署功能的.现在换了VS2013那个部署功能完全弄不清方向.最后在 ...