This is to help remember the maven compiler plugin that can resolve a common issue that people have experienced with Maven projects in IntelliJ.

There is a possibility of the version resetting to an old version of Java which would fail to automatically import and leave everything red. Set the source and target versions to make it clear what versions it should be using.

Issue reference:

Java version resetting to 1.5

IntelliJ Maven compiler options

Via properties: Setting the -source and -target of the Java Compiler

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

Via the plugin:

<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>

Java 9+ can use whole numbers. More information by Nguyen the champion: Maven Compiler Plugin

Leave a comment

Your email address will not be published. Required fields are marked *