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 ...
随机推荐
- Python监控Windows下的文件变化
windows下监控文件系统的变化.用python非常方便.实例代码例如以下,非常easy.也不多说了. import os import win32file import win32con ACTI ...
- CSU1256 天朝的单行道(spfa)
1256: 天朝的单行道 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 281 Solved: 92 [Submit][Status][pid=12 ...
- 如何根据Ip获取地址信息--Java----待整理完善!!!
如何根据Ip获取地址信息--Java----待整理完善!!! QQWry.dat数据写入方法: http://www.cnblogs.com/xumingxiang/archive/2013/02/1 ...
- django的hello world 项目
一.新建一个django项目bester: django-admin startproject bester 二.在bester项目中建一个叫polls的应用程序: cd bester/ python ...
- unity hide/show text
using UnityEngine;using System.Collections; public class PlayerController:MonoBehaviour{ public U ...
- Nginx(二):虚拟主机配置
什么是虚拟主机? 虚拟主机使用的是特殊的软硬件技术,它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机,每台虚拟主机都可以是一个独立的网站,可以具有独立的域名,具有完整的Intemet服务器功 ...
- 使用自定义的按钮替换默认的<input type='file'>
可以通过让默认的input type = 'file'按钮透明度变为0,并且让它刚好覆盖在自定义的按钮上,来实现此效果: 将它写成一个jQuery插件: (function($){ $.fn.brow ...
- 解决MAC下ctags -R无效的问题
MAC下自带了ctags,与我们常用的是不同的. 我们需要去重新下载一个ctags并重新安装 1.去http://ctags.sourceforge.net/下载Ctags的最新版本源代码 2.tar ...
- Django视图层之路由配置系统(urls)
视图层之路由配置系统(urls) URL配置(URLconf)就像Django 所支撑网站的目录.它的本质是URL与要为该URL调用的视图函数之间的映射表:你就是以这种方式告诉Django,对于这个U ...
- Windows进程间各种通信方式浅谈
1 Windows进程间通信的各种方法 进程是装入内存并准备执行的程序,每个进程都有私有的虚拟地址空间,由代码.数据以及它可利用的系统资源(如文件.管道等)组成. 多进程/多线程是Windows操作系 ...