Maven项目设置修改jdk版本

  1. 在maven的安装目录${MAVEN_HOME}/conf/找到settings.xml文件,在里面添加如下代码:
<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>
  1. 局部配置,在项目中的pom.xml指定jdk版本
<build>  

    <plugins>  

        <plugin>  

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-compiler-plugin</artifactId>  

                <version>3.7</version>  

                <configuration>  

                    <source>1.8</source>  

                    <target>1.8</target>  

                </configuration>  
                
            </plugin>  
            
        </plugins>  
        
</build>
发布了27 篇原创文章 · 获赞 1 · 访问量 1317

猜你喜欢

转载自blog.csdn.net/Sakitaf/article/details/104709264