Solve the JDK version problem of maven

Add the following code to the POM file

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>14</source><!-- 源代码开发版本 -->
                    <target>14</target><!-- java编译版本 -->
                    <encoding>UTF8</encoding> <!-- 项目的编码 -->
                </configuration>
            </plugin>
        </plugins>
    </build>

Or specify the JDK version in the setting file (recommended)

<profile>    
    <id>jdk-14</id>    
     <activation>    
        <activeByDefault>true</activeByDefault>    
        <jdk>14</jdk>    
      </activation>    
    <properties>    
        <maven.compiler.source>14</maven.compiler.source>    
        <maven.compiler.target>14</maven.compiler.target>
        <maven.compiler.compilerVersion>14</maven.compiler.compilerVersion> 
    </properties>    
</profile>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>