When running a JUnit test, using IntelliJ IDEA, I get
How can I correc
Make sure right depency is selected. File > Project Structure
Select your project and navigate to Dependencies tab. Select right dependancy from dropdown or create new.
In IntelliJ IDEA 14.1 the "Target bytecode version" is in a different place.
The following change worked for me:
File > Settings... > Build, Execution, Deployment > Compiler > Java Compiler : change Target bytecode version from 1.5 to 1.8
I found another way to run into this error. You can get this if you have been re-organizing your directory structure, and one of your poms is pointing to the old parent which no-longer configures javac (because that configuration was moved to a middle level). If this happens the top level defaults to 1.5 and the misbehaving lower level pom inherits it.
So another thing to check when you see this error is that your pom structure is matching your directory structure properly.
From one moment to the other I also got this error without a clear reason. I changed all kinds of settings on the compiler/module etc. But in the end I just recreated the IntelliJ project by reimporting the Maven project and the issue was solved. I think this is a bug.
IntelliJ 12 129.961
Have you looked at your build configuration it should like that if you use maven 3 and JDK 7
<build>
<finalName>SpringApp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
...
</plugins>
...
</build>
I resolved it by setting the field blank:
Settings > Compiler > Java Compiler > Project bytecode version
Than IntelliJ uses the JDK default version.