maven 编译报错 java: -source 1.5 中不支持switch 中存在字符串

xiaoxiao2021-02-28  114



maven 编译报错 java: -source 1.5 中不支持switch 中存在字符串

maven项目的pom文件里面添加

<build> <defaultGoal>compile</defaultGoal> <pluginManagement> <plugins>  <plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-compiler-plugin</artifactId>  <configuration>  <source>1.7</source>  <target>1.7</target>  </configuration>  </plugin> </plugins> </pluginManagement> </build>

 

 

可以在本地的setting文件里面添加

 

<profile>             <id>jdk-1.7</id>             <activation>                 <activeByDefault>true</activeByDefault>                 <jdk>1.7</jdk>             </activation>             <properties>                 <maven.compiler.source>1.7</maven.compiler.source>                 <maven.compiler.target>1.7</maven.compiler.target>                 <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>             </properties>         </profile>

 

配置文件修改编译格式

 

即可用JDK1.7编译!

转载请注明原文地址: https://www.6miu.com/read-33800.html

最新回复(0)