让mahout0.7在hadoop2.0环境下运行

由于官方打的jar包是用1.0环境下的,所以要想在2.0下运行,必须重新打包,重新打包前修改几个pom文件就可以,现已经测试通过:

1、根pom文件修改如下:

<hadoop.version>2.5.0</hadoop.version>
<!-- 将原来的1.0改为2.0版本-->
<!-- 并注释掉hadoop1.0的依赖-->
 <!--dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>${hadoop.version}</version>
        <exclusions>
          <exclusion>
            <groupId>net.sf.kosmosfs</groupId>
            <artifactId>kfs</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-util</artifactId>
          </exclusion>
          <exclusion>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
          </exclusion>
          <exclusion>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
          </exclusion>
          <exclusion>
            <groupId>oro</groupId>
            <artifactId>oro</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-2.1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-api-2.1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>servlet-api-2.5</artifactId>
          </exclusion>
          <exclusion>
            <groupId>tomcat</groupId>
            <artifactId>jasper-runtime</artifactId>
          </exclusion>
          <exclusion>
            <groupId>tomcat</groupId>
            <artifactId>jasper-compiler</artifactId>
          </exclusion>
          <exclusion>
            <groupId>xmlenc</groupId>
            <artifactId>xmlenc</artifactId>
          </exclusion>
          <exclusion>
            <groupId>net.java.dev.jets3t</groupId>
            <artifactId>jets3t</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>core</artifactId>
          </exclusion>
        </exclusions>
      </dependency-->

2、在mahout-core、mahout-examples、mahout-integration工程的pom文件中增加如下代码

 <profiles>
    <profile>
      <id>hadoop1</id>
      <!--activation>
        <property>
          <name>!hadoop.version</name>
        </property>
      </activation-->
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-core</artifactId>
           <version>1.0.0</version>
            <scope>compile</scope>
             <exclusions>
          <exclusion>
            <groupId>net.sf.kosmosfs</groupId>
            <artifactId>kfs</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-util</artifactId>
          </exclusion>
          <exclusion>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
          </exclusion>
          <exclusion>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
          </exclusion>
          <exclusion>
            <groupId>oro</groupId>
            <artifactId>oro</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-2.1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jsp-api-2.1</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>servlet-api-2.5</artifactId>
          </exclusion>
          <exclusion>
            <groupId>tomcat</groupId>
            <artifactId>jasper-runtime</artifactId>
          </exclusion>
          <exclusion>
            <groupId>tomcat</groupId>
            <artifactId>jasper-compiler</artifactId>
          </exclusion>
          <exclusion>
            <groupId>xmlenc</groupId>
            <artifactId>xmlenc</artifactId>
          </exclusion>
          <exclusion>
            <groupId>net.java.dev.jets3t</groupId>
            <artifactId>jets3t</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>core</artifactId>
          </exclusion>
        </exclusions>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>hadoop2</id>
      <activation>
        <property>
          <name>hadoop.version</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-mapreduce-client-common</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-mapreduce-client-core</artifactId>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

3、在根目录下执行 mvn package -Phadoop2 -DskipTests 重新生成jar包

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值