Mahout错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1

时间:2013-09-03 18:08:13

标签: maven-3 mahout

我是一名Mahout新手。

我正在尝试实施推荐人,后面的帖子讨论了这个推荐人: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>

1 个答案:

答案 0 :(得分:0)

你有没有尝试过:

rm -rf ~/.m2/
mvn clean install

清理maven存储库,因为有时某些依赖项会产生麻烦。

我强烈建议你做

mvn -Dmaven.test.skip=true install

mvn -DskipTests install

因为对我来说{i}对mahout的测试从未成功过mvn install