Berikut ini adalah akar penyebab java 1.5:
Perhatikan juga bahwa saat ini pengaturan sumber default adalah 1,5 dan pengaturan target default adalah 1,5, terlepas dari JDK yang Anda jalankan dengan Maven. Jika Anda ingin mengubah default ini, Anda harus menetapkan sumber dan target.
Referensi: Plugin Kompiler Apache Mavem
Berikut ini rinciannya:
Pom.xml polos
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pluralsight</groupId>
<artifactId>spring_sample</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
Plugin berikut diambil dari versi POM yang diperluas (POM Efektif),
Ini bisa didapat dengan perintah ini dari baris perintah yang C:\mvn help:effective-pom
saya taruh di sini potongan kecil bukan seluruh pom.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Bahkan di sini Anda tidak melihat di mana versi java didefinisikan, mari menggali lebih lanjut ...
Unduh plugin, Apache Maven Compiler Plugin »3.1 sebagai tersedia di jar dan buka di alat kompresi file seperti 7-zip
Lintasi tabung dan temukan
plugin.xml
file di dalam folder
maven-compiler-plugin-3.1.jar \ META-INF \ maven \
Sekarang Anda akan melihat bagian berikut dalam file,
<configuration>
<basedir implementation="java.io.File" default-value="${basedir}"/>
<buildDirectory implementation="java.io.File" default-value="${project.build.directory}"/>
<classpathElements implementation="java.util.List" default-value="${project.testClasspathElements}"/>
<compileSourceRoots implementation="java.util.List" default-value="${project.testCompileSourceRoots}"/>
<compilerId implementation="java.lang.String" default-value="javac">${maven.compiler.compilerId}</compilerId>
<compilerReuseStrategy implementation="java.lang.String" default-value="${reuseCreated}">${maven.compiler.compilerReuseStrategy}</compilerReuseStrategy>
<compilerVersion implementation="java.lang.String">${maven.compiler.compilerVersion}</compilerVersion>
<debug implementation="boolean" default-value="true">${maven.compiler.debug}</debug>
<debuglevel implementation="java.lang.String">${maven.compiler.debuglevel}</debuglevel>
<encoding implementation="java.lang.String" default-value="${project.build.sourceEncoding}">${encoding}</encoding>
<executable implementation="java.lang.String">${maven.compiler.executable}</executable>
<failOnError implementation="boolean" default-value="true">${maven.compiler.failOnError}</failOnError>
<forceJavacCompilerUse implementation="boolean" default-value="false">${maven.compiler.forceJavacCompilerUse}</forceJavacCompilerUse>
<fork implementation="boolean" default-value="false">${maven.compiler.fork}</fork>
<generatedTestSourcesDirectory implementation="java.io.File" default-value="${project.build.directory}/generated-test-sources/test-annotations"/>
<maxmem implementation="java.lang.String">${maven.compiler.maxmem}</maxmem>
<meminitial implementation="java.lang.String">${maven.compiler.meminitial}</meminitial>
<mojoExecution implementation="org.apache.maven.plugin.MojoExecution">${mojoExecution}</mojoExecution>
<optimize implementation="boolean" default-value="false">${maven.compiler.optimize}</optimize>
<outputDirectory implementation="java.io.File" default-value="${project.build.testOutputDirectory}"/>
<showDeprecation implementation="boolean" default-value="false">${maven.compiler.showDeprecation}</showDeprecation>
<showWarnings implementation="boolean" default-value="false">${maven.compiler.showWarnings}</showWarnings>
<skip implementation="boolean">${maven.test.skip}</skip>
<skipMultiThreadWarning implementation="boolean" default-value="false">${maven.compiler.skipMultiThreadWarning}</skipMultiThreadWarning>
<source implementation="java.lang.String" default-value="1.5">${maven.compiler.source}</source>
<staleMillis implementation="int" default-value="0">${lastModGranularityMs}</staleMillis>
<target implementation="java.lang.String" default-value="1.5">${maven.compiler.target}</target>
<testSource implementation="java.lang.String">${maven.compiler.testSource}</testSource>
<testTarget implementation="java.lang.String">${maven.compiler.testTarget}</testTarget>
<useIncrementalCompilation implementation="boolean" default-value="true">${maven.compiler.useIncrementalCompilation}</useIncrementalCompilation>
<verbose implementation="boolean" default-value="false">${maven.compiler.verbose}</verbose>
<mavenSession implementation="org.apache.maven.execution.MavenSession" default-value="${session}"/>
<session implementation="org.apache.maven.execution.MavenSession" default-value="${session}"/>
</configuration>
Lihatlah kode di atas dan cari tahu 2 baris berikut
<source implementation="java.lang.String" default-value="1.5">${maven.compiler.source}</source>
<target implementation="java.lang.String" default-value="1.5">${maven.compiler.target}</target>
Semoga berhasil.