IDEA运行项目时出现java不支持发行版本5

如图
在这里插入图片描述
原因是项目使用的jdk版本与本地的jdk环境不同导致,解决方案有两种:

一. 需要修改配置

修改为使用的jdk版本
在这里插入图片描述

同时修改项目结构中的jdk版本
在这里插入图片描述

为了避免每次都需要重新设置,可以在默认设置中修改项目环境均为本地jdk环境
在这里插入图片描述

二.

  • 在工程的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>
    
  • 或者,添加properties节点

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
发布了37 篇原创文章 · 获赞 7 · 访问量 1600

猜你喜欢

转载自blog.csdn.net/weixin_43862596/article/details/105044534