由于来源1.5,无法建立套件目标

时间:2018-09-29 17:54:52

标签: java maven

当我清理项目并干净运行时,一切正常。然后,当我尝试以build ..身份运行并将目标设置为package时,出现此错误:

<?php

 $xml = file_get_contents('note.xml');
 $dom = new DOMDocument();
 $dom->loadXML($xml);
 $xpath = new domXpath($dom);

 foreach ($xpath->query('//standard[header="MECHANICAL"]/description') as $mechdescription){
 $mecharray[] = $mechdescription->nodeValue ;
}
 foreach ($mecharray as $mechanicaldescription){
 echo $mechanicaldescription;
}

?>

大多数行上的multicatch看起来像这样,但是当我运行该应用程序时,该应用程序运行正常。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project smart.mirror: Compilation failure: Compilation failure:
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/ApplicationView.java:[29,65] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/App.java:[119,49] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Login.java:[86,51] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Login.java:[136,49] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Application.java:[88,65] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Application.java:[158,103] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] /C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/Application.java:[120,48] multi-catch statement is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable multi-catch statement)

我不确定source 1.5意味着什么,我已经在google上搜索了如何在软件包构建中更改Maven源代码,但是找不到任何东西。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:5)

如果尚未在(super)pom.xml中明确包含它,请尝试直接配置该maven-compiler-plugin。 添加以下内容:

<build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>