为什么我在Java中收到“diamond operator is not supported in -source 1.5”错误?

huangapple go评论72阅读模式
英文:

Why i get error diamond operator is not supported in -source 1.5 in Java?

问题

项目是在Intellij IDEA中使用Maven创建的。
以下是我的设置:
为什么我在Java中收到“diamond operator is not supported in -source 1.5”错误?
为什么我在Java中收到“diamond operator is not supported in -source 1.5”错误?

为什么在尝试“构建项目”时会出现错误“java:不支持钻石操作符-source 1.5
(请使用-source 7或更高版本启用钻石操作符)”?

英文:

Project was created in Intellij IDEA with Maven.
This is my settings:
为什么我在Java中收到“diamond operator is not supported in -source 1.5”错误?
为什么我在Java中收到“diamond operator is not supported in -source 1.5”错误?

Why I get error java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
when try build project?

答案1

得分: 2

在您的项目对象模型(pom.xml)文件中,您需要将编译器源版本和目标版本更改为1.8。通过其他方式,例如首选项或其他方式进行更改,最终将由Maven在下次构建时重置,因为Maven默认使用编译器版本1.5。

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
英文:

In your project object model (pom.xml) file you need to change the compiler source and target version to 1.8. Changing it any other way, via preferences or otherwise will ultimately be reset by Maven on next build due to priority. Maven by default has a compiler version of 1.5.

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

</details>



huangapple
  • 本文由 发表于 2020年8月27日 21:09:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63616718.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定