Same problem fixed for me by setting JAVA_HOME environment variable to point to the JDK with right version.
My source and destination java version in maven-compiler-plugin were 11, java -version was also on version 11, but my JAVA_HOME was pointing to JDK-1.8.
Check JAVA_HOME again by using a terminal instead of IDE:
Linux:
echo $JAVA_HOME
Win:
echo %JAVA_HOME%
Then Build your project in the same terminal:
mvn clean package