79098457

Date: 2024-10-17 14:08:22
Score: 0.5
Natty:
Report link

I think the configurations for java 8 with maven-compiler-plugin and java 17 with maven-compiler-plugin are to be done in different ways.

For java 8 and lower version it is as below,

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

For java 9+ version the configurations are as below,

  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <release>8</release>
        </configuration>
      </plugin>

References:

  1. https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html
  2. https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: code_buddy