Maven 项目错误:-source 1.5 中不支持 Diamond/multicatch 运算符 [英] Maven project Error: Diamond/multicatch operator not supported in -source 1.5

查看:34
本文介绍了Maven 项目错误:-source 1.5 中不支持 Diamond/multicatch 运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法构建我的 maven java web 应用程序,因为以下两个错误:

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)

我很困惑,因为我的项目使用的是 java 1.8.0,我从未实际使用过 1.5

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?

我在 pom.xml 中添加以下行后尝试构建它,但没有成功:

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>

推荐答案

尝试在你的 pom 中声明 maven-compiler-plugin.

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>

这篇关于Maven 项目错误:-source 1.5 中不支持 Diamond/multicatch 运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆