【问题标题】:strings in switch are not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable strings in switch) [duplicate]-source 1.5 [ERROR] 不支持 switch 中的字符串(使用 -source 7 或更高版本启用 switch 中的字符串)[重复]
【发布时间】:2017-03-05 15:49:43
【问题描述】:

我使用的是 Java 1.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 版本。\

任何帮助都会很棒。 非常感谢您的帮助。 附上截图。

【问题讨论】:

  • @Rajender Pal maven 在这里扮演什么角色?请详细说明,可能是原因。
  • @jeremy Heiler - 在我的项目中哪里可以找到这个文件?
  • 这是你的 pom.xml 文件。
  • @RajenderPal pom.xml 在您的项目下可见。

标签: java eclipse maven


【解决方案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 来验证更改。

【讨论】:

  • 非常感谢大家。它奏效了。
猜你喜欢
  • 1970-01-01
  • 2014-05-21
  • 2018-01-18
  • 1970-01-01
  • 2023-03-20
  • 2018-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多