1、在项目的pom.xml中加入下面的代码就能解决(加入插件)

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

然后重新update maven就可以自动改成1.8了

2、在项目的pom.xml中加入下面的代码(加入属性)

<properties>
  <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target>
</properties

3、在maven的setting中加入下面的代码,也可以解决(推荐)

  <profiles>
    <profile>
        <id>jdk-1.8</id>
        <activation>
            <activeByDefault>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>
  </profiles>

相关文章:

  • 2021-10-14
  • 2022-02-25
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2021-05-28
  • 2021-08-04
  • 2021-10-25
  • 2021-11-24
相关资源
相似解决方案