Ошибка проекта Maven: оператор Diamond/multicatch не поддерживается в источнике 1.5
Я не могу создать свое веб-приложение maven java из-за следующих двух ошибок:
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
![enter image description here]()
![enter image description here]()
Что может вызвать эту проблему и как ее решить?
Я попытался построить его после добавления строк follwing в pom.xml, но без succes:
<properties>
<sourceJdk>1.8</sourceJdk>
<targetJdk>1.8</targetJdk>
</properties>
Ответы
Ответ 1
Попробуйте объявить maven-compiler-plugin
в вашей папке.
<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
Вы также можете добавить его таким же образом, включив его в свой pom.xml
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>