在学习接口的JDK8新特性
出现报错extension methods are not supported at language level ‘1.5’
解决办法一:
1.File --> Project Structure --> Module -->Language level,设置如图
2.File -->Settings --> Compiler -->Java Compiler 设置Project bytecode version;同时修改项目对应的Per-module bytecode version.如图所示
解决方法二:
在pom.xml中添加如下插件:
原因是尽管IDEA中已经设置了jdk的版本,maven中项目的配置可能覆盖了jdk的版本,所以需要在pom.xml文件中重新设置
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.csdn</groupId>
<artifactId>java-base</artifactId>
<version>1.0-SNAPSHOT</version>
<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>