0

我在服务器上有一个hadoop环境,现在我在本地PC上开发,我在Eclipse中编写了一个MapReduce类(仅覆盖Mapper类),并在main方法中设置了相应的配置,现在我想在Eclipse中运行我的程序,但我在“调试为:Junit 测试”期间遇到问题,获取错误信息如下:


java.lang.Exception:方法main应该没有参数......


Java 虚拟机启动器

找不到主类:TestMapReduceDecodeAndCompressSelfSetting.class。程序将会退出。

4

1 回答 1

0

要在 Windows 机器上的 Eclipse 中运行 Map Reduce,您需要下载 hadoop-7682 java 文件。在 conf 文件中引用此文件,如下所示。

config.set("fs.file.impl", "com.assignment.WinLocalFileSystem");

这里 WinLocalFileSystem 是 java 类。

附上示例代码供您参考。

Configuration config = new Configuration();
    config.set("mapreduce.input.keyvaluelinerecordreader.key.value.separator", " ");
    config.set("mapred.textoutputformat.separator", " --> ");
    config.set("fs.file.impl", "com.assignment.WinLocalFileSystem");

    String inputPath="In\\VISA_Details.csv";
    Path inPath=new Path(inputPath);
    String outputPath = "C:\\Users\\Desktop\\Hadoop Learning\\output\\run1";
    Path outPath=new Path(outputPath);

    Job job = new Job(config,"VISA: Total count on each day");
    job.setInputFormatClass(TextInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);

    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(Text.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    job.setMapperClass(VisaMapper.class);
    job.setReducerClass(VisaReducer.class);

    FileInputFormat.setInputPaths(job, inPath );
    FileOutputFormat.setOutputPath(job, outPath);

    System.out.println(job.waitForCompletion(true));
于 2013-11-26T09:43:16.443 回答