IntelliJ target bytecode reverting

You need to specify the source and target versions in your pom.xml file, but since the maven-compiler-plugin is added by default, an easier way to do that would be to set the following properties:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

FYI.

I still had this problem despite setting the pom.xml with both the settings above from the answers as mentioned by @isapir and @carlos-a-ibarra respectively.

I discovered this was due to an Intellij setting:

screen shot of intellij Maven settings

This config can be found in Build,Execution,Deployment > Build Tools > Maven > Importing

By default, it is set to the 'Internal JRE' setting, which in the latest version of Idea is 11. I had to select it to use the 1.8 JDK the project was configured to use.

This is annoying, because if you have a mix of 11 and 8 projects, you'll have to manually toggle this setting back and forth.

It caused the module output to always fall back to 11 every time the pom.xml was reimported.

intellij idea project module settings

It's a really annoying bug in IntelliJ.


You need to dd this to your POM:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>