簡體   English   中英

如何在Eclipse中的m2e / Installed maven中配置工具鏈插件

[英]How to configure toolchains plugin in m2e / Installed maven in Eclipse

目前我在我的Windows機器上安裝了maven(Apache Maven 3.3.9) 和Java(Java版本:1.8.0_91) 我有一個使用Java Version 1.6.0_31開發的java應用程序。

由於Apache maven(3.3.9)與之前版本的Java(1.8之前的版本不直接兼容,因此我已經包含了工具鏈插件來編譯和運行Java 1.6項目。 我可以使用命令提示符進行成功構建。

但是當我嘗試使用eclipse與eclipse m2e插件構建相同的項目或使用eclipse-> Windows-> Preferences-> Maven-> Installations添加外部maven(3.3.9)時 ,我收到以下錯誤。

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Expected root element 'settings' but found 'toolchains' (position: START_TAG seen ...OOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">... @45:114)  @ U:\POC\Repo\.m2\toolchains.xml, line 45, column 114
[WARNING] 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Replenishment Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Replenishment ---
[INFO] Deleting C:\Users\xagh9\workspace\Replenishment\target
[INFO] 
[INFO] --- maven-toolchains-plugin:1.1:toolchain (default) @ Replenishment ---
[INFO] Required toolchain: jdk [ vendor='sun' version='1.6' ]
[ERROR] No toolchain found for type jdk
[ERROR] Cannot find matching toolchain definitions for the following toolchain types:
jdk [ vendor='sun' version='1.6' ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.105 s
[INFO] Finished at: 2017-01-04T12:02:08+11:00
[INFO] Final Memory: 8M/116M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project Replenishment: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.6' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

注意:使用Java_1.8,我可以在沒有工具鏈插件的情況下成功構建項目。 但是配置了工具鏈插件我面臨着這個問題。 任何人都可以幫我解決這個問題。

所需的toolchains.xml存在於maven配置文件夾以及存儲庫的.m2文件夾中

更新:Maven編譯器插件配置: 插入

在eclipse運行配置中更改目標后解決如下。

Eclipse運行配置

問題是eclipse不會自動讀取toolchains.xml。 我們必須在目標中手動指定。 我通過引用此鏈接修復此問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM