有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

源代码1.5不支持交换机中的java字符串[错误](使用源代码7或更高版本启用交换机中的字符串)

我使用的是Java1.8.101版本。当我运行maven clean install时,我发现了一个错误

strings in switch are not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable strings in switch).

我不知道为什么,因为我已经在使用java 1.8.101版本了\

任何帮助都会很好。 事先非常感谢你的帮助。 附上截图

java


共 (1) 个答案

  1. # 1 楼答案

    正如@Jeremy所建议的那样,在pom.xml文件中做一个条目,如下所示:

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    

    并在命令行上使用mvn clean install来验证更改