原本在eclipse中正常使用的项目,导入idea时发现不能正常使用,需要修改的地方挺多的,也可能是原来项目的配置文件不太规范,idea的规则要比eclipse严格一些,很多在eclipse中正常使用的,导入到idea时就会报错。最重要的JDK的修改注意事项多大6处。有一些地方可以通过配置文件进行规避。
1、File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner
2、File | Settings | Build, Execution, Deployment | Compiler | Java Compiler
3、Project Structure | Project Settings | Project
4、Project Structure | Project Settings | Modules
这个地方每个模块都要设置
5、Project Structure | Platforms Settings | Modules
6、tomcat的jdk:
对于3、4、5的设置可以通过在pom文件中添加配置项进行设置,配置文件添加如下配置
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
多模块的项目,每个pom文件(包含父模块)都需要设置,否则第4处那里会不正确,会莫名的出现Cannot resolve symbol XXX,而且不管是 “File” -> “Invalidate Caches / Restart”重启还是maven的Reinport,都无效。另外执行maven中的compile(或者install、package)时,可以一下控制台第一行调用的jdk是否跟项目的jdk一致,如果不一致请检查以上几处配置。