在导入或新建一些项目的时候,有时候会出现一些问题,如Diamond types are not supported at language level '5'错误,但是通过idea的Project Structure设置后发现每次刷新都会重置回原来的级别,设置无效果,可以通过pom来指定Language level级别,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yc</groupId>
<artifactId>industrial-application-bed</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>industrial-application-bed</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<!--依赖坐标-->
</dependencies>
<!--指定Language Level级别-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
如图: