【问题标题】:Mahout error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1Mahout 错误:无法执行目标 org.codehaus.mojo:exec-maven-plugin:1.2.1
【发布时间】:2013-09-07 01:44:02
【问题描述】:

我是 Mahout 新手。

我正在尝试实现以下帖子中讨论的 Recommender:https://code.google.com/p/unresyst/wiki/CreateMahoutRecommender

我尝试使用 NetBean IDE,收到以下错误:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project mahoutrec: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging. 

以下是Java代码:

package com.mahout;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;
import java.io.IOException;

import org.apache.commons.cli2.OptionException; 
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator;

public class UnresystBoolRecommend {

public static void main(String... args) throws FileNotFoundException, TasteException,     IOException, OptionException {

     //create data source (model) - from the csv file            
    File ratingsFile = new File("hdfs://------/user/hdfs/mahout/dummy-bool.csv");                        
    DataModel model = new FileDataModel(ratingsFile);

    // create a simple recommender on our data
    CachingRecommender cachingRecommender = new CachingRecommender(new SlopeOneRecommender(model));

    // for all users
    for (LongPrimitiveIterator it = model.getUserIDs(); it.hasNext();){
        long userId = it.nextLong();

        // get the recommendations for the user
        List<RecommendedItem> recommendations = cachingRecommender.recommend(userId, 10);

        // if empty write something
        if (recommendations.size() == 0){
            System.out.print("User ");
            System.out.print(userId);
            System.out.println(": no recommendations");
        }

        // print the list of recommendations for each 
        for (RecommendedItem recommendedItem : recommendations) {
            System.out.print("User ");
            System.out.print(userId);
            System.out.print(": ");
            System.out.println(recommendedItem);
        }
    }        
   }
} 

期待回复,非常感谢您的帮助。

编辑:

我已经更改了 Pom.xml,有一些版本兼容性问题现在对我来说可以正常工作。

这是更新后的 Pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>org.wikimedia</groupId>
<artifactId>mahoutrec</artifactId>
<version>0.2-CDH4</version>
<packaging>jar</packaging>
<name>mahoutrec</name>
<url>http://github.com/whym/wikihadoop</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
    <repository>
        <id>cloudera-2</id>
        <name>Cloudera Repository</name>
        <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
    </repository>
   </repositories>
  <dependencies>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.0.0-cdh4.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce</artifactId>
        <version>2.0.0-cdh4.3.0</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-client</artifactId>
        <version>2.0.0-cdh4.3.0</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.13</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

        <dependency>
  <groupId>org.apache.mahout</groupId>
  <artifactId>mahout-core</artifactId>
  <version>0.4</version>
   </dependency>


   </dependencies>
   <build>
    <plugins>
        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.8.1</version>
            <configuration>
                <linksource>true</linksource>
                <includeDependencySources>true</includeDependencySources>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                                <mainClass>org.wikimedia.wikihadoop.StreamWikiDumpInputFormat</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>${project.build.directory}/dependency</directory>
        </resource>
    </resources>
  </build>
  </project>

【问题讨论】:

    标签: maven-3 mahout


    【解决方案1】:

    你有没有尝试过:

    rm -rf ~/.m2/
    mvn clean install
    

    清理 maven 仓库,因为有时有些依赖会造成麻烦。

    我强烈建议这样做

    mvn -Dmaven.test.skip=true install
    

    mvn -DskipTests install
    

    因为对我来说mvn install 对 mahout 的测试从未成功。

    【讨论】:

    • 感谢您的信息。我尝试了使用 Netbean IDE 的代码,并且没有单独安装 maven。我更改了 pm.xml 中的依赖项,现在它工作正常。
    • 也许您可以在单独的答案中描述您放入 pom.xml 的哪些依赖项解决了您的问题,以便其他人遇到同样的问题时可以使用它。
    • 我有同样的问题,你的提问和更新并没有真正的帮助。您能否更具体地作为 Dragan 的建议?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 2014-01-25
    • 1970-01-01
    • 2013-12-03
    • 2016-11-24
    • 2014-07-20
    • 2013-12-27
    相关资源
    最近更新 更多