使用maven编译shiro-samples时报错:
[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:
<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/目录):
<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
在尝试使用Maven编译Apache Shiro的samples时遇到错误。通过配置和理解toolchain,成功解决了问题。推荐查阅官方文档以获取更多关于Maven toolchain的详细信息。

221

被折叠的 条评论
为什么被折叠?



