欢迎喜欢深入了解推荐系统和mahout的兄弟加入群 推荐系统之Mahout 135918911
一直在学习mahout,工作中使用的是0.7跑算法,进行测试,但是在使用maven导入eclipse中构建的时候出现了问题,
首先由于m2e的lifeStyle覆盖问题,两个插件不能使用,如下图
m2e插件现在已经被eclipse托管,在看eclipse官方网站看过文档后终于找到解决方案,
解决方案如下:打开我们出现问题的pom文件
例如 mahout-core下的pom文件,出错的地方,表示m2e不知道怎么处理该插件(M2E plugin execution not covered)
鼠标放到错误地方会出现
选择第二项Mark goal run as .....,如果第三项(Discover new m2e connectors)能解决最好,有的时候eclipse会出现一些connectors更新,不过很少,大多数都是使用第二种方法解决,选择后我们会看见错误提示消失
同理mahout-examples下的pom文件也这样解决如下图
同理 mahout-integration下的pom文件也这样解决如下图
同理mahout-math下的pom文件也这样解决如下图
mahout-math的pom build中插件配置是存在问题,我们最后在解决这个问题,下面继续maven问题的解决
我们如下图操作
然后
我们打开lifecycle Mapping的配置文件将全部的
<action >
<ignore />
</action >
换成
<action>
<execute/>
</action >
或者直接将下面粘贴进去
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>1.6</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>2.1</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-collection-codegen-plugin</artifactId>
<versionRange>1.0</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>1.6</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>2.1</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-collection-codegen-plugin</artifactId>
<versionRange>1.0</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
注意红色部分,默认是忽略而不是执行,需要修改成执行,或者把以上直接拷贝过去
上面的maven-antrun-plugin,mahout-collection-codegen-plugin插件我们设置的都是执行
记得保存文件,然后在我们打开lifecycle Mapping的配置文件的配置菜单上重载红色框框下面按钮
前面说到mahout-math pom中 build配置是存在问题的,
木配置把生成的类包的存放目录添加进classpath中去
(生成路径>${project.build.directory}/generated-sources ,测试目录${project.build.directory}/generated-test-sources)
如果目录不同,请自己对应。
<configuration>
<!--<mainExcludes>-->
<!--<mainExclude>**/AbstractBooleanList.java</mainExclude>-->
<!--<mainExclude>**/BooleanArrayList.java</mainExclude>-->
<!--<mainExclude>**/BooleanBufferConsumer.java</mainExclude>-->
<!--</mainExcludes>-->
<!--<testExcludes>-->
<!--<testExclude>**/BooleanArrayListTest.java</testExclude>-->
<!--</testExcludes>-->
<outputDirectory>${project.build.directory}/generated-sources/mahout</outputDirectory>
<!--<mainExcludes>-->
<!--<mainExclude>**/AbstractBooleanList.java</mainExclude>-->
<!--<mainExclude>**/BooleanArrayList.java</mainExclude>-->
<!--<mainExclude>**/BooleanBufferConsumer.java</mainExclude>-->
<!--</mainExcludes>-->
<!--<testExcludes>-->
<!--<testExclude>**/BooleanArrayListTest.java</testExclude>-->
<!--</testExcludes>-->
<outputDirectory>${project.build.directory}/generated-sources/mahout</outputDirectory>
<testOutputDirectory>${project.build.directory}/generated-test-sources/mahout</testOutputDirectory>
</configuration>
新增多个java文件源码包,maven本身是不支持的,我们这里需要一个插件来解决这个问题
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/mahout</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-test-sources/mahout</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/mahout</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-test-sources/mahout</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
或者我们直接粘贴0.8版本的build配置,0.8修正了这个问题,下面是0.8的配置
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-collection-codegen-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!--<mainExcludes>-->
<!--<mainExclude>**/AbstractBooleanList.java</mainExclude>-->
<!--<mainExclude>**/BooleanArrayList.java</mainExclude>-->
<!--<mainExclude>**/BooleanBufferConsumer.java</mainExclude>-->
<!--</mainExcludes>-->
<!--<testExcludes>-->
<!--<testExclude>**/BooleanArrayListTest.java</testExclude>-->
<!--</testExcludes>-->
<outputDirectory>${project.build.directory}/generated-sources/mahout</outputDirectory>
<testOutputDirectory>${project.build.directory}/generated-test-sources/mahout</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/mahout</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-test-sources/mahout</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- create test jar so other modules can reuse the math test utility classes. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<configuration>
<appendedResourcesDirectory>../src/main/appended-resources</appendedResourcesDirectory>
<resourceBundles>
<resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
</resourceBundles>
<supplementalModels>
<supplementalModel>supplemental-models.xml</supplementalModel>
</supplementalModels>
</configuration>
</plugin>
</plugins>
</build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-collection-codegen-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!--<mainExcludes>-->
<!--<mainExclude>**/AbstractBooleanList.java</mainExclude>-->
<!--<mainExclude>**/BooleanArrayList.java</mainExclude>-->
<!--<mainExclude>**/BooleanBufferConsumer.java</mainExclude>-->
<!--</mainExcludes>-->
<!--<testExcludes>-->
<!--<testExclude>**/BooleanArrayListTest.java</testExclude>-->
<!--</testExcludes>-->
<outputDirectory>${project.build.directory}/generated-sources/mahout</outputDirectory>
<testOutputDirectory>${project.build.directory}/generated-test-sources/mahout</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/mahout</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-test-sources/mahout</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- create test jar so other modules can reuse the math test utility classes. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<configuration>
<appendedResourcesDirectory>../src/main/appended-resources</appendedResourcesDirectory>
<resourceBundles>
<resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
</resourceBundles>
<supplementalModels>
<supplementalModel>supplemental-models.xml</supplementalModel>
</supplementalModels>
</configuration>
</plugin>
</plugins>
</build>
更新配置
或者我们直接把下面改好的配置替换原有build配置(下面的是0.8的配置) ,建议还是使用上面第一种
运行maven插件 clean install -Dmaven.test.skip=true -e -X
下面是apache的一个下载正式版本的依赖,对有些人可能有用
<repository>
<id>apache.releases</id>
<name>Apache Snapshot Repository</name>
<url>https://repository.apache.org/service/local/repositories/releases/content/</url>
</repository>
<id>apache.releases</id>
<name>Apache Snapshot Repository</name>
<url>https://repository.apache.org/service/local/repositories/releases/content/</url>
</repository>
相关推荐
mahout-core-0.7.jar,注意版本hadoop-1.0.x,eclipse-3.7。(mahout0.7不支持hadoop-2.2),由mahout-distribution-0.7.tar.gz源码构建生成jar包,可以直接引入。
mahout 0.7 src, mahout 源码包, hadoop 机器学习子项目 mahout 源码包
mahout0.7版本,源码,可修改源码并自己编译,使用java语言编写,maven编译
mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7mahout-integration-0.7
mahout 中的类库解析,API,是学习mahout的好帮手
mahout0.9不能运行在hadoop2中,会报interface错误,用此新编译后的包,可实现mahout+hadoop2的运行环境,其中包括编译后的包及源码。
mahout in action中的example codes进行maven编译时由于maven相关jar包的URL的重定位,故无法进行有效编译,需要下载相关jar包进行手动加载!
用于测试mahout中的决策树 ,即Partial Implementation用到的测试jar包。所谓的测试其实也只是把相应的数据可以打印出来,方便单机调试,理解算法实现原理而已。
Mahout是基于Hadoop之上的机器学习和数据挖掘的一个分布式框架项目。搞机器智能学习算法,这个是首选。本文给出一个完整的编译运行示例,让有兴趣的同行少走段弯路,多一份参考!
运行博客推荐程序需要注意的地方: 1. 打开mysql,增加blog数据库;... 2. 修改blog.xml(和Readme.txt同目录)的docBase为本地目录,放在tomcat的conf\...版本:Spring3+Struts2+Hibernate3+Hadoop1.0.4+Mahout0.7+Mysql5
教你成功运行mahout的taste webapp例子,网上的很多资料说的不清楚,或者版本冲突。正确的版本是jdk1.6 maven3.0.5 mahout0.5 。 摸索良久,亲测有效!
maven_mahout_template-mahout-0.8
mahout_help,mahout的java api帮助文档,可以帮你更轻松掌握mahout
mahout0.11版本,源码,可修改源码并自己编译,使用java语言编写,maven编译
mahout-examples-0.11.1 mahout-examples-0.11.1-job mahout-h2o_2.10-0.11.1 mahout-h2o_2.10-0.11.1-dependency-reduced mahout-hdfs-0.11.1 mahout-integration-0.11.1 mahout-math-0.11.1 mahout-math-0.11.1 ...
MAHOUT实战 MAHOUT IN ACTION
If you are a Java developer and want to use Mahout and Machine Learning to solve Big Data analytics use-cases then this book is for you. Familiarity with shell-scripts is assumed but no prior ...
mahout-core-0.9.jar+mahout-core-0.8.jar+mahout-core-0.1.jar
mahoutAlgorithms源码分析 mahout代码解析