当我尝试编译我的Maven时,出现以下错误:
strings in switch are not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable strings in switch)
它抱怨切换。见图片。 我还附加了POM.XML。
答案 0 :(得分:2)
Switch
作为参数的 string
仅受Java 1.7或更高版本支持。您使用目标版本1.5(这是maven的默认版本)进行编译。
在pom中添加以下几行:
<properties>
<maven.compiler.source><Java_version></maven.compiler.source>
<maven.compiler.target><Java_version></maven.compiler.target>
</properties>
例如<Java_version>
为1.7或更高
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
有关更多信息,请参见https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html