部署shiro官方源码时,执行maven命令出错

部署shiro官方源码时,执行maven命令会报下面错误:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project shiro-root: 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

解决办法:

打开maven的安装目录或者免安装的conf文件夹,修改里边的toolchains.xml文件,

下面是maventoolchains.xml文件代码,最后一部分是添加进来的,注意修改自己jdk的安装目录。

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 
  3 <!--
  4 Licensed to the Apache Software Foundation (ASF) under one
  5 or more contributor license agreements.  See the NOTICE file
  6 distributed with this work for additional information
  7 regarding copyright ownership.  The ASF licenses this file
  8 to you under the Apache License, Version 2.0 (the
  9 "License"); you may not use this file except in compliance
 10 with the License.  You may obtain a copy of the License at
 11 
 12     http://www.apache.org/licenses/LICENSE-2.0
 13 
 14 Unless required by applicable law or agreed to in writing,
 15 software distributed under the License is distributed on an
 16 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17 KIND, either express or implied.  See the License for the
 18 specific language governing permissions and limitations
 19 under the License.
 20 -->
 21 
 22 <!--
 23  | This is the toolchains file for Maven. It can be specified at two levels:
 24  |
 25  |  1. User Level. This toolchains.xml file provides configuration for a single user,
 26  |                 and is normally provided in ${user.home}/.m2/toolchains.xml.
 27  |
 28  |                 NOTE: This location can be overridden with the CLI option:
 29  |
 30  |                 -t /path/to/user/toolchains.xml
 31  |
 32  |  2. Global Level. This toolchains.xml file provides configuration for all Maven
 33  |                 users on a machine (assuming they‘re all using the same Maven
 34  |                 installation). It‘s normally provided in
 35  |                 ${maven.home}/conf/toolchains.xml.
 36  |
 37  |                 NOTE: This location can be overridden with the CLI option:
 38  |
 39  |                 -gt /path/to/global/toolchains.xml
 40  |
 41  | The sections in this sample file are intended to give you a running start at
 42  | getting the most out of your Maven installation.
 43  |-->
 44 <toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 45   xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
 46 
 47   <!-- 
 48    | With toolchains you can refer to installations on your system. This 
 49    | way you don‘t have to hardcode paths in your pom.xml. 
 50    | 
 51    | Every toolchain consist of 3 elements: 
 52    | * type: the type of tool. An often used value is ‘jdk‘. Toolchains-aware 
 53    |   plugins should document which type you must use. 
 54    | 
 55    | * provides: A list of key/value-pairs. 
 56    |   Based on the toolchain-configuration in the pom.xml Maven will search for 
 57    |   matching <provides/> configuration. You can decide for yourself which key-value 
 58    |   pairs to use. Often used keys are ‘version‘, ‘vendor‘ and ‘arch‘. By default 
 59    |   the version has a special meaning. If you configured in the pom.xml ‘1.5‘ 
 60    |   Maven will search for 1.5 and above.
 61    |   
 62    | * configuration: Additional configuration for this tool.
 63    |   Look for documentation of the toolchains-aware plugin which configuration elements
 64    |   can be used.   
 65    |
 66    | See also http://maven.apache.org/guides/mini/guide-using-toolchains.html
 67    |
 68    | General example
 69 
 70   <toolchain>
 71     <type/>
 72     <provides> 
 73       <version>1.0</version> 
 74     </provides> 
 75     <configuration/>
 76   </toolchain>
 77    
 78    | JDK examples
 79 
 80   <toolchain>
 81     <type>jdk</type>
 82     <provides>
 83       <version>1.5</version>
 84       <vendor>sun</vendor>
 85     </provides>
 86     <configuration>
 87       <jdkHome>/path/to/jdk/1.5</jdkHome>
 88     </configuration>
 89   </toolchain>
 90   <toolchain>
 91     <type>jdk</type>
 92     <provides>
 93       <version>1.6</version>
 94       <vendor>sun</vendor>
 95     </provides>
 96     <configuration>
 97       <jdkHome>/path/to/jdk/1.6</jdkHome>
 98     </configuration>
 99   </toolchain> 
100   -->
101 <!--插入下面代码-->
102   <toolchain>
103     <type>jdk</type>
104     <provides>
105       <version>1.6</version>
106       <vendor>sun</vendor>
107     </provides>
108     <configuration>
109         <!--这里是你安装jdk的文件目录-->
110       <jdkHome>C:\java\jdk1.6.0_10</jdkHome>
111     </configuration>
112   </toolchain>
113 </toolchains>

 

文章来自:http://www.cnblogs.com/Ahanu/p/5051090.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3