step1: 找到本身項目的pom.xml文件,添加下圖黃色區域代碼(文末附上的有代碼:能夠直接複製)html

step2: 保存一下更改後的的pom.xml文件,而後項目右鍵>Maven>Update project.... 更新一下工程:apache

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~來條華麗的分割線~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~app
配置先後對比:maven

在這附上在pom.xml中須要添加的代碼:oop
須要更改jdk版本的小夥伴能夠直接把這段代碼添加到pom.xml文件<project>標籤下:post
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- </plugins>
- </build>
補充:
還有另一種更改方式:
更改前:ui

選中JRE System Libraray ,右鍵>Properties,勾選 Alternate JRE: 選擇版本jdk1.8, 如圖:spa

點擊OK,便可..net
更該後:xml

最終補充:
還有一種更簡單的設置方式:---全局設置
找到maven的setting文件,在profiles節點下添加以下代碼:(若添加在profiles節點外將不生效)
- <profile>
- <id>jdk18</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <jdk>1.8</jdk>
- </activation>
- <properties>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
- </properties>
- </profile>
id節點下的jdk18是別名,能夠隨意起