gpt4 book ai didi

spring - 使用 Javaconfig 配置 HADOOP 作业

转载 作者:可可西里 更新时间:2023-11-01 16:22:04 29 4
gpt4 key购买 nike

我现在正在关注Spring HADOOP的介绍页面http://blog.springsource.org/2012/02/29/introducing-spring-hadoop/

示例配置是基于 xml 的。以下代码描述了 wordCount 示例。

<!-- define the job -->
<hdp:job id="word-count"
input-path="/input/" output-path="/ouput/"
mapper="org.apache.hadoop.examples.WordCount.TokenizerMapper"
reducer="org.apache.hadoop.examples.WordCount.IntSumReducer"/>

<!-- execute the job -->
<bean id="runner" class="org.springframework.data.hadoop.mapreduce.JobRunner"
p:jobs-ref="word-count"/>

有没有办法用 Javaconfig 配置这个例子?

最佳答案

@Configuration
@EnableHadoop
@PropertySource(value={"classpath:config/hadoop.properties"})
public class HadoopConfiguration extends SpringHadoopConfigurerAdapter {
@Override
public void configure(HadoopConfigConfigurer config) throws Exception {
Properties props = new Properties();
config.fileSystemUri("hdfs://");
config.withProperties(props).property("propkey", "propvalue").and();
}
}

关于spring - 使用 Javaconfig 配置 HADOOP 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16415725/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com