1、Check the jdk of the project(Ctrl+Alt+shift+S)
File ->Project Structure->Project Settings ->Project
2.View the jdk of the project (Ctrl+Alt+shift+S)
File -> Project Structure-> Project Settings -> Modules -> (name of the project to be modified) -> Sources ->
3.View Java configuration in idea
File ->Setting ->Build,Execution,Deployment -> Compiler -> Java Compiler
If the above three steps still fail
Clear IDEA cache and restart IDEA
File->Invalidate Caches/Restart