简体   繁体   中英

How to configure toolchains plugin in m2e / Installed maven in Eclipse

Currently i am using maven(Apache Maven 3.3.9) & Java(Java version: 1.8.0_91) installed in my windows machine. I have a java application which was developed using Java Version 1.6.0_31 .

Since Apache maven(3.3.9) is not directly compatible with the previous version of Java(Prior to 1.8) I have included toolchains plugin to compile and run the project with Java 1.6 . I can do a successful build using command prompt.

But when I try to build the same project using eclipse with eclipse m2e plugin or by adding the external maven(3.3.9) using eclipse->Windows->Preferences->Maven->Installations , I am getting the below error.

[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

Note: With Java_1.8 I can build the project successfully without toolchains plugin. But with toolchains plugin configured I am facing this issues. Can anyone help me to resolve this.

The required toolchains.xml is present in both maven config folder as well as in the .m2 folder of the repository

UPDATE: Maven compiler plugin configuration: 插入

The resolved after changing goals in eclipse run configuration as below.

Eclipse运行配置

The problem is eclipse is not automatically reading the toolchains.xml. We have to manually specify in the goals. I fixed this by referring the this Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM