When running a JUnit test, using IntelliJ IDEA, I get
How can I correct this?
Maven build works fine. (That's why I believe this in IDEA configuration issue)
Most likely you have incorrect compiler options imported from Maven here:
Also check project and module bytecode (target) version settings outlined on the screenshot.
Other places where the source language level is configured:
Maven default language level is 1.5 (5.0), you will see this version as the Module language level on the screenshot above.
This can be changed using maven-compiler-plugin configuration inside pom.xml
:
<project> [...] <build> [...] <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> [...] </build> [...] </project>
or
<project> [...] <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> [...] </project>
IntelliJ IDEA will respect this setting after you Reimport the Maven project in the Maven Projects tool window:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With