如何在m2e中配置toolchains插件/在eclipse中安装maven

hpxqektj  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(692)

目前我正在使用安装在windows机器上的maven(apachemaven 3.3.9)和java(java版本:1.8.0Ώ91)。我有一个java应用程序,它是用java版本1.6.0\u31开发的。
由于apachemaven(3.3.9)与java的前一个版本(1.8之前)不直接兼容,因此我加入了toolchains插件来用java1.6编译和运行项目。我可以使用命令提示符进行成功的构建。
但是,当我尝试使用带有eclipsem2e插件的eclipse或者通过使用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

注意:使用java1.8,我可以在没有toolchains插件的情况下成功地构建项目。但配置了工具链插件后,我面临着这个问题。谁能帮我解决这个问题。
所需的toolchains.xml既存在于maven config文件夹中,也存在于存储库的.m2文件夹中
更新:maven编译器插件配置:

yrwegjxp

yrwegjxp1#

在更改eclipse运行配置中的目标之后,问题得到了解决,如下所示。

问题是eclipse没有自动读取toolchains.xml。我们必须在目标中手动指定。我通过引用此链接修复了此问题

相关问题