您的位置:首页 > 运维架构 > Apache

使用mven编译apache-shiro出错

2016-03-24 21:54 961 查看
使用maven编译shiro-samples时报错:

[html] view
plain copy

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:

1.1:toolchain (default) on project shiro-samples: 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/toolch

ains.xml file.

这是因为shiro-root-1.2.4.pom中使用了maven-toolchains-plugin,而maven中没有配置toolchain导致无法编译(toolchain可以指定编译时使用的jdk版本),见shiro-root-1.2.4.pom中的maven-toolchains-plugin:

[html] view
plain copy

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-toolchains-plugin</artifactId>

<version>1.1</version>

<configuration>

<toolchains>

<jdk>

<version>1.6</version>

<vendor>sun</vendor>

</jdk>

</toolchains>

</configuration>

<executions>

<execution>

<goals>

<goal>toolchain</goal>

</goals>

</execution>

</executions>

</plugin>

意思是使用sun的1.6版本的JDK来编译项目,toolchain可以在%MAVEN_HOME%\conf\toolchains.xml中定义(也可以在repository目录下定义,如默认的${user.home}/.m2/目录):

[html] view
plain copy

<toolchain>

<type>jdk</type>

<provides>

<version>1.6</version>

<vendor>sun</vendor>

</provides>

<configuration>

<jdkHome>C:\Program Files\Java\jdk1.6.0_45</jdkHome>

</configuration>

</toolchain>

这里定义了1.6版本的JDK的目录,当然,你也可以定义多个toolchain。

ok,大功告成!

如果需要了解更多关于toolchain的信息,可以看这里:
http://maven.apache.org/guides/mini/guide-using-toolchains.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: