在IDEA做maven项目时总会遇到错误:Error: java: 错误: 不支持发行版本5,这是因为在IDEA的java编译器默认版本太低了,有两种方法可以更正:
第一种:
![](https://i-blog.csdnimg.cn/blog_migrate/7a404df1e5f720708e2ef9e08ba184d7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/b87da96a9fa18afb15032cbe25e60676.png)
此处选择高于10的版本即可
但是第一种办法在再次修改pom.xml时,他还是会自动变更为1.5版本
第二种方法:
在pom.xml中引入指定maven-compiler-plugin的版本,此项设置会同时影响LanguageLevel和JavaCompiler,在修改之后会默认使用此处的版本
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!--source 和 target根据个人需要自己修改-->
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>