你应该检查以下事项:
如果您使用Maven,请检查pom.xml
中的编译器插件“source”和“target”属性是否为11.在这种情况下,您的模块语言级别配置是从该pom.xml
配置导入的。
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
要么
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
如果您的pom.xml
有错误的源或目标级别,您可能需要右键单击| Maven |改变pom.xml
后重新进口。如果您使用Gradle,则应检查您是否具有类似的配置。
在IntelliJ IDEA 2018.2.4中使用Maven 3.5.4进行测试
尝试将编译器目标字节码版本设置为11。
为此,请转到Settings
- Build Execution Deployment
- Compiler
- Java compiler
并将模块的目标字节码版本设置为11。