jre becomes 1.5 after Maven Updata project

The official Maven documentation has the following description:

The compiler plugin is used to compile project source files since version 3.0. The default compiler used to compile Java source files is javax.tools.JavaCompiler (if you are using java 1.6). If you want to force the plugin to To use javac, you must configure the plugin option forceJavacCompilerUse. At the same time, it should be noted that the default settings of the source option and target option are currently 1.5, which has nothing to do with the JDK version when running Maven. If you want to change these default settings, you can refer to Setting the -source and -target of the Java Compiler. description to set the source and target options.

Two workarounds

  1. <profile>
    <id>jdk-1.8</id>
    true</activebydefault>
    <jdk>1.8</jdk>
    </activation>
    <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.compilerversion>1.8</maven.compiler.compilerversion>
    </properties>
    </profile>

    Change the 1.8 in the code article to your own jdk version, it will take effect globally

  2. Add the following to the specific project pom file Change the 1.8 in
    write picture description here
    the code to your own jdk version

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324678722&siteId=291194637