原因为:idea设置的jdk版本与自己项目的编译版本不匹配导致。 解决方法如下: project Structure -> Modules -> 选择项目 -> 点击sources,更改 Language Level为对应的JDK版本