【问题标题】:Failed to Build Application Getting Error::No toolchain found for type jdk无法构建应用程序出现错误::没有找到 jdk 类型的工具链
【发布时间】:2019-03-10 14:09:36
【问题描述】:

我为此尝试了不同的解决方案,但对我不起作用,

请查看错误日志和toolchain.xml 文件。

这些是错误日志:

[INFO] --- maven-toolchains-plugin:1.1:toolchain (default) @ ad-api ---
[INFO] Required toolchain: jdk [ vendor='sun' version='1.8' ]
[ERROR] No toolchain found for type jdk
[ERROR] Cannot find matching toolchain definitions for the following toolchain types:
jdk [ vendor='sun' version='1.8' ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.619 s
[INFO] Finished at: 2018-10-05T08:56:24+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project ad-api: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.8' ]
[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

当我将 1.8 版更新到 jdk1.8._172 时出现上述错误

下面是我的 pom.xml

 <plugins>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
   </plugin>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-toolchains-plugin</artifactId>
      <executions>
         <execution>
            <goals>
               <goal>toolchain</goal>
            </goals>
         </execution>
      </executions>
      <configuration>
         <toolchains>
            <jdk>
               <version>jdk1.8.0_172</version>
               <vendor>sun</vendor>
            </jdk>
         </toolchains>
      </configuration>
   </plugin>

   <plugin>
      <artifactId>maven-resources-plugin</artifactId>
      <configuration>
         <encoding>${project.build.sourceEncoding}</encoding>
      </configuration>
   </plugin>

</plugins>

我已经在toolchain.xml中定义了jdk路径

<toolchains>
    <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.8</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
      <jdkHome>C:\Program Files\Java\jdk1.8.0_172</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

请帮助解决问题。 提前致谢。

【问题讨论】:

    标签: java eclipse maven pom.xml toolchain


    【解决方案1】:

    将 pom 中的版本改为 1.8 而不是 jdk1.8.0_172

                    <configuration>
                        <toolchains>
                            <jdk>
                                <version>1.8</version>
                                <vendor>sun</vendor>
                            </jdk>
                        </toolchains>
                    </configuration>
    

    【讨论】:

    • Same Error::Required toolchain: jdk [ vendor='sun' version='1.8' ]
    • 这个错误看起来不一样,你能添加完整的错误日志吗?
    • 你把你的 toolchains.xml 文件放在哪里了?如果不是,它应该在 m2 文件夹中,您需要使用“--global-toolchains”提供位置,或者只是将该文件移动到 m2 文件夹
    • 我只将 toolchain.xml 文件放在 m2 文件夹中。
    • 是您的文件名 toolchains.xml 吗?cos 看起来问题是它无法读取 xml 文件。
    猜你喜欢
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多