In a Maven project for managing Java application, to enforce usage of a specific Java version, you will need to add configuration option to the maven-compiler-plugin.
To achieve this, simply add the appropriate source
and target
options to the maven-compiler-plugin
, for example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Change the source
and target
to the project’s appropriate Java version.