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

[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)


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

catch (InstantiationException | IllegalAccessException e)


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

最佳答案

如果尚未在(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>

关于java - 由于来源1.5,无法建立套件目标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52571041/

10-09 15:42
查看更多