Intellij IDEA Module 的Language Level的问题
最近从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的问题的更多相关文章
- [转]IDEA 出现编译错误 Multi-catches are not supported a this language level 解决方法
转自 http://blog.csdn.net/qq465235530/article/details/53897538 首先出现这种问题是说明正在使用低版本jdk编译其本身不支持的语法,出现这种情况 ...
- language level in Intellij IDEA
The Language level setting sets which features the code assistance in the editor should support. For ...
- intellij idea jdk language level
jdk的新的版本会兼容旧的版本. 如果安装了新的jdk,但是还是希望使用旧版本的特性,这个可以使用jdk language level来实现. 比如安装了jdk8,但是希望用7,那么language ...
- idea中的language level 介绍
language level 介绍 其他 IDE 没有看到类似 language level 的设置,所以这个功能应该算是 IntelliJ IDEA 特有的,可是 IntelliJ IDEA 官网也 ...
- idea language level 介绍
language level 介绍 其他 IDE 没有看到类似 language level 的设置,所以这个功能应该算是 IntelliJ IDEA 特有的,可是 IntelliJ IDEA 官网也 ...
- 自动重置Language level 5 与 Java Complier 1.5
Intellij IDEA用Maven来构建项目,若pom.xml没有指定版本,总是默认Language level 5 与 Java Compiler 1.5. 以下是两种修改方式: 1. 手动进行 ...
- idea开发工具下报Set language level to 6-@Override in interfaces的解决方法
idea开发工具下报Set language level to 6-@Override in interfaces的解决方法 实现接口时报如下错误:Set language level to 6-@O ...
- diamond types are not supported at this language level
在intellij导入git项目之后出现 diamond types are not supported at this language level错误 或者String等报错 File->P ...
- idea报错Diamond types are not supported at this language level
project structure中的project ,SDK选择1.8,Project language level选择8 project structure中的module,选择Language ...
随机推荐
- STL应用之set
之前在解决一道算法题的时候,应用到set,特意对这个stl的容器类做了一些了解.在我的印象中,set就是一个元素不重复的集合,而事实上也正是这样的.无论从MSDN还是任何其它地方,都会告诉我们set的 ...
- php将session保存到数据库的类实例(php版本需要大于5.4)
这里实现了一个把session存储到数据库的类,包括数据表的创建.类的使用.php的配置. 可以更好地进行用户控制管理. 做项目的时候,有一个需求,是要实现禁止一个账号两处登录.同时要统计当前在线用户 ...
- ps抠图
*套索工具:简单抠图 *多边形套索工具:简单抠图 *磁性套索工具:可以自动贴着走 *快速选择工具抠图,使用方法:主要控制画笔大小. *魔术棒抠图,使用方法:主要控制容差大小 *钢笔抠图,常见商业抠图 ...
- Hadoop2.5.2源码编译及导入Eclipse
前言:由于官网提供的64位hadoop是没有编译的,所以当我们用到64位的hadoop时,需要在自己的64位linux系统上编译hadoop源码.另外,要想在eclipse里查看hadoop源码,修改 ...
- 428. Pow(x, n)【medium】
Implement pow(x, n). Notice You don't need to care about the precision of your answer, it's acceptab ...
- posix多线程--互斥量
多线程程序在线程间共享数据时,如果多个线程同时访问共享数据就可能有问题.互斥量是解决多个线程间共享数据的方法之一. 1.互斥量初始化两种方式:(1)静态初始化 #include <pthread ...
- . net 源代码调试
对于 .net framework 中的代码,光拿 Reflector 看是不够过瘾的,如果能够调试进去就好了! 其实,微软是提供了一套 sourcecode 的下载的: http://referen ...
- 原始tab栏切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- C++Primer 4th edition读书笔记-第二章
1 变量的定义用于为变量分配存储空间,还可以为变量指定初始值.在一个程序中,变量有且只有一个定义.声明用于向程序表明变量的名字和类型.定义也是声明:当定义变量时,我们声明了它的类型和名字.可以通过使用 ...
- LeetCode: Swap Nodes in Pairs 解题报告
Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For exam ...