I am new to maven, and I find that though I change the facet of the jdk of the project to 1.8, every time I "update maven",it will get back to jdk 1.6.
Why is that?
I installed jdk 1.8 in my windows, and I am using eclipse.
I read Specify JDK for Maven to use and add the following but it does not work.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.8</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
2.1. The Maven compiler accepts this command with –target and –source versions. If we want to use the Java 8 language features, the –source should be set to 1.8. Also, for the compiled classes to be compatible with JVM 1.8, the –target value should be 1.8. The default value for both of them is the 1.6 version.
Jenkins >= 1.520 (1.531. 1 for LTS) requires Java 6 thus Maven jobs must be launched with a JDK >= 6. Jenkins >= 1.612 (1.625.
The Maven tool uses JDK version 11.0. 10. The default JDK is set to 13.0.
javac -source 1.8 (is an alias for javac -source 8 ) java.
The version of the JDK that maven will use is set in the maven-compiler-plugin
like so:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source> <!-- use java 8 -->
<target>1.8</target>
</configuration>
</plugin>
See Setting the -source and -target of the Java Compiler
for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With