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


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>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值