Java 由于源代码1.5,无法生成包目标

Java 由于源代码1.5,无法生成包目标,java,maven,Java,Maven,当我清理项目并以干净的方式运行时,一切正常。当我尝试以构建方式运行时。。并将目标设置为package I receive此错误: [ERROR]未能在project smart.mirror上执行目标org.apache.maven.plugins:maven编译器插件:3.1:compile(默认编译):编译失败:编译失败: [错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Applic

当我清理项目并以干净的方式运行时,一切正常。当我尝试以构建方式运行时。。并将目标设置为package I receive此错误:

[ERROR]未能在project smart.mirror上执行目标org.apache.maven.plugins:maven编译器插件:3.1:compile(默认编译):编译失败:编译失败:
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/ApplicationView.java:[29,65]在-source 1.5中不支持多捕获语句
[错误](使用-source 7或更高版本启用多捕获语句)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/App.java:[119,49]在-source 1.5中不支持多捕获语句
[错误](使用-source 7或更高版本启用多捕获语句)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Login.java:[86,51]源代码1.5中不支持lambda表达式
[错误](使用-source 8或更高版本启用lambda表达式)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Login.java:[136,49]源代码1.5中不支持多捕获语句
[错误](使用-source 7或更高版本启用多捕获语句)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Application.java:[88,65]源代码1.5中不支持多捕获语句
[错误](使用-source 7或更高版本启用多捕获语句)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/views/Application.java:[158103]lambda表达式在-source 1.5中不受支持
[错误](使用-source 8或更高版本启用lambda表达式)
[错误]/C:/Users/user/Desktop/smart.mirror/src/main/java/iezon/smart/mirror/Application.java:[120,48]在-source 1.5中不支持多捕获语句
[错误](使用-source 7或更高版本启用多捕获语句)
大多数行上的multicatch看起来像这样,但当我运行应用程序时,应用程序运行良好

catch (InstantiationException | IllegalAccessException e)

我不确定sourcing 1.5是什么意思,我在Google上搜索了如何在包构建中更改Maven源代码,但找不到任何东西。感谢您的帮助。

如果您还没有在(super)pom.xml中明确包含maven编译器插件,请尝试直接配置它。 添加以下内容:

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

[...]
org.apache.maven.plugins
maven编译器插件
3.8.0
1.8
1.8
[...]

如果(super)pom.xml中还没有明确包含maven编译器插件,请尝试直接配置它。 添加以下内容:

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

[...]
org.apache.maven.plugins
maven编译器插件
3.8.0
1.8
1.8
[...]

将此添加到my
pom.xml后生成成功!非常感谢恩克里格,如果可能的话,他会接受答案。回答得好。源代码1.5指的是Java版本,而@nkrieg建议将其更改为1.8(Java 8)。将其添加到my
pom.xml
后,构建成功!非常感谢恩克里格,如果可能的话,他会接受答案。回答得好。源代码1.5指的是Java版本,而@nkrieg建议将其更改为1.8(Java8)。