bug——java: 错误: 无效的源发行版:16

Maven项目报错:java: 错误: 无效的源发行版:16

运行maven时候,报错:java: 错误: 无效的源发行版:16

解决办法:

方案一:修改java compiler

菜单栏的file—setting—build、execution、deployment----compiler—java compiler【修改为对应使用的版本】

方案二:修改Project 的language level

菜单栏的file -> Project Structure -> 查看language level与SDK和project 里使用的是否相符

方案三:pom.xml中配置maven插件

在pom.xml中配置maven插件:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.8.1version>
                   
                <configuration>
                    <source>8source>
                    <target>8target>
                configuration>
            plugin>
        plugins>
    build>

方案四:修改模块的language level

project - modules - 选中对应模块 - sources选择对应level,包括右侧的dependences也改为对应版本
bug——java: 错误: 无效的源发行版:16_第1张图片

方案五:修改本地maven的settings.xml文件

找到本地Maven的settings.xml文件,修改编译版本

在settings.xml的profiles标签下添加:

 <profile>
     <id>developmentid>
     <activation>
         <jdk>8jdk>
         <activeByDefault>trueactiveByDefault>
     activation>
     <properties>
         <maven.compiler.source>8maven.compiler.source>
         <maven.compiler.target>8maven.compiler.target>
         <maven.compiler.compilerVersion>8maven.compiler.compilerVersion>
     properties>
 profile>

bug——java: 错误: 无效的源发行版:16_第2张图片

你可能感兴趣的:(bug,java,bug,maven,idea)