- 1. 编译版本不匹配
- 2. 当前项目jdk版本不支持
File ->Project Structure->Project Settings ->Project
1.8必须对应8
查看当前工程(module)的jdk和项目的是否相同2、IDEA中使用Maven构建项目是Target bytecode version自动变为1.5 因为maven中没有指定jdk,所以才会扫描为默认的jdk版本 查看设置java编译器版本(Target bytecode version)
File–>Setting…–>Build,Execution,Deployment–>Compiler–>Java Compiler 设置相应Module
将target bytecode version的合适版本如:jdk1.8 将上面的1.5改为1.8
解决方案:在pom.xml中添加maven-compiler-plugin这样就不会自动变为1.5了
maven-compiler-plugin 3.5.1 ${java.version} ${java.version} UTF-8



