首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IntelliJ Idea编译报错:请使用 -source 7 或更高版本以启用 diamond 运算符

IntelliJ Idea编译报错:请使用 -source 7 或更高版本以启用 diamond 运算符

作者头像
用户2146693
发布2019-08-08 11:23:25
2.3K0
发布2019-08-08 11:23:25
举报
文章被收录于专栏:架构师进阶架构师进阶

IntelliJ Idea maven项目编译报错:

Information:Using javac 1.7.0_79 to compile java sources
Information:java: javacTask: 源发行版 1.7 需要目标发行版 1.7
Information:java: Errors occurred while compiling module 'wsdlutils'
Information:2016/4/13 16:42 - Compilation completed with 1 error and 0 warnings in 1s 805ms
Error:java: Compilation failed: internal java compiler error

参考文章[http://blog.csdn.net/wave_1102/article/details/47671019]都不能解决问题。

原来在IntelliJ Idea 默认的jdk是1.5。以上的修改都不会起作用的。见【https://maven.apache.org/plugins/maven-compiler-plugin/】

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.

在项目的pom文件中加以下内容:

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

官网上也有说明[https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html]

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.4</source>
          <target>1.4</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档