While building a new maven java project, sometimes the below error occurs:
Solution:
Add the following Maven compiler plugin to pom.xml
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
Also change the Java version on the following places in IntellijIdea:
Open Module Settings(F4) -> Project Settings -> Project -> Project SDK
Open Module Settings(F4) -> Project Settings -> Modules -> Sources -> Language level
File -> Settings (ctrl+alt+s) -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version
Module -> Target bytecode version