java - 通过 Ant 清理dist-执行一个 jar 以不同的名字出现?

标签 java hadoop ant jar build.xml

我正在使用hadoop,需要从/ src文件中的所有类创建一个合并的.jar文件。每次我尝试创建它时,它都出现在WordCount.jar下,而不是在下面的代码中声明的Twitter.jar下:

import java.util.Arrays;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class Twitter {
    public static void runJob(String[] input, String output) throws Exception {
        Configuration conf = new Configuration();
        Job job = new Job(conf);
        job.setJarByClass(Twitter.class);
        job.setReducerClass(TwitterReducer.class);
        job.setMapperClass(TwitterMapper.class);
   
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);
        Path outputPath = new Path(output);
        FileInputFormat.setInputPaths(job, StringUtils.join(input, ","));
        FileOutputFormat.setOutputPath(job, outputPath);
        outputPath.getFileSystem(conf).delete(outputPath, true);
        job.waitForCompletion(true);
        }
    public static void main(String[] args) throws Exception {
        runJob(Arrays.copyOfRange(args, 0, args.length - 1), args[args.length - 1]);
    }
}

因此,我不确定出什么问题了吗? .jar本身中的文件与/ src文件夹中的文件完全相同。

最佳答案

Jar文件的名称与其中的类名称无关。您需要检查Ant构建文件,特别是创建jar的目标。创建Jar文件的Ant任务通常是 jar 任务,并且可以通过destfile属性指定文件名。

关于java - 通过 Ant 清理dist-执行一个 jar 以不同的名字出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807877/

相关文章:

java - 使用 MinGW 将 C 库编译为 DLL

java - 为什么调用 "this "必须是构造函数中的第一个语句?

apache-spark - 计算给定日期范围内pyspark窗口中的行数

java - "Ant not recognized as an internal or external command"- 开发Spring应用教程

java - 使用 Javac/Ant 编译 1 个文件也会编译指定文件中的导入文件/类

java - "No persistence unit with name ' 产品 ' found"

java - 单击按钮时 Activity 中出现 NullPointerException

maven - 在 ARM (Raspbian) 上编译 Hadoop 2.7.1

hadoop - 使用 '-tagFile' 选项的项目文件名字段,使用 PigStorage '-tagFile' 加载,Pig 0.14

java - 如何对涉及多个项目的大 Ant 脚本执行良好的重构?