I have the problem mentioned in the title. You could say that this thread duplicates another one: How do I turn off error validation for annotations in IntelliJ IDEA?
If your project has multiple modules, also check that every module uses language level 6 or above, or use the project's language level (see Project Settings > Modules > xxx > Language level).
You may need to reload your project once it is modified.