zoukankan      html  css  js  c++  java
  • IDEA 使用Maven构建项目提示:Error:java: 错误: 不支持发行版本 5

    IDEA 使用Maven构建项目提示:Error:java: 错误: 不支持发行版本 5

    在IDEA使用Maven构建项目提示总提示 Error:java: 错误: 不支持发行版本 5,是因为Intellij IDEA用Maven来构建项目,若pom.xml没有指定版本,总是默认Language level 5 与 Java Compiler 1.5。

    解决办法:

    方法一(手动修改)

    • File -> Settings -> Java Compiler -> Target bytecode version = 8

    • File -> Project Structure -> Language level : 8 - Lambdas,type annotations etc

    方法二(修改pom.xml):

    • 方式一:添加properties节点 (重启项目后生效)

      <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <!--修改Language level-->
          <maven.compiler.source>1.8</maven.compiler.source>
          <!--修改Java Compiler-->
          <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
      
    • 方式二:pom.xml中添加build节点

      <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>
      
  • 相关阅读:
    小X的密码破译
    小X的加法难题
    足球联赛
    机器分配
    化装晚会
    Soundex编码
    迷之阶梯
    使用JMeter做压力测试
    SCOI 2010 序列操作
    动态求区间K大值(权值线段树)
  • 原文地址:https://www.cnblogs.com/fate-pc/p/13301543.html
Copyright © 2011-2022 走看看