Maven project Error: Diamond/multicatch operator not supported in -source 1.5 [duplicate]

风格不统一 提交于 2019-11-29 18:27:14

问题


This question already has an answer here:

  • Maven Compilation Error: (use -source 7 or higher to enable diamond operator) 4 answers

I can't build my maven java web application, because of the following two errors:

diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)

multi-catch statement is not supported in -source 1.5
  (use -source 7 or higher to enable multi-catch statement)

I'm confused, because i use java 1.8.0 for my project, i never have actually used 1.5

What could be causing this problem and how do i solve it?

I tried to build it after adding the follwing lines in the pom.xml, but without succes:

 <properties>
        <sourceJdk>1.8</sourceJdk>
        <targetJdk>1.8</targetJdk>
 </properties>

回答1:


Try declaring the maven-compiler-plugin in your pom.

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>



回答2:


You can also add it in this way as well by including this in your pom.xml

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


来源:https://stackoverflow.com/questions/25912398/maven-project-error-diamond-multicatch-operator-not-supported-in-source-1-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!