maven更改專案jdk版本
阿新 • • 發佈:2019-01-27
使用eclipse新建maven專案時,預設的jdk版本是1.5,每次多要改成自己下載的1.8,很不方便,所以查詢了資料,在這裡總結一下:
方法一:
開啟windows->preference->java Build Path->Libraries,如圖選中1.5版本,選擇右邊remove
然後點選右邊add Library->JRE System Library
選擇安裝的jdk版本。finish後點擊apply,大功告成。
方法二:
新建maven專案,在pom.xml檔案中指定jdk版本:
<build> <plugins但是每次建立maven專案後都要在pom.xml檔案中新增,不是很便利。> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
方法三:
在maven的安裝目錄找到settings.xml檔案,在裡面新增如下程式碼
<profile>
<id>jdk-1.8</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>