gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 19:53:05 30 4
gpt4 key购买 nike

目前我正在使用 ma​​ven(Apache Maven 3.3.9) & Java(Java version: 1.8.0_91) 安装在我的 windows 机器上。我有一个使用 Java 版本 1.6.0_31 开发的 java 应用程序。

因为 Apache maven(3.3.9) 不直接兼容以前的 Java 版本(1.8 之前),所以我包含了 toolchains plugin 使用 Java 1.6 编译和运行项目。我可以使用命令提示符成功构建。

但是,当我尝试使用带有 eclipse m2e 插件 的 eclipse 构建相同的项目时,或者使用 eclipse-> 添加external maven(3.3.9) 时Windows->Preferences->Maven->Installations,我收到以下错误。

[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编译器插件配置: Plugin

最佳答案

在 eclipse 运行配置中更改目标后解决,如下所示。

Eclipse run configuration

问题是 eclipse 没有自动读取 toolchains.xml。我们必须在目标中手动指定。我通过引用 this Link 解决了这个问题

关于java - 如何在 Eclipse 中的 m2e/Installed maven 中配置工具链插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41453789/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com