1,从spark的example中找到KafkaWordCount.scala文件复制到idea编辑器中,引入包:
IDEA中运行KafkaWordCount程序-LMLPHP
2,编辑configuration,
    (1)KafkaWordCountProducer
    选择KafkaWordCount.scala中的KafkaWordCountProducer方法
    VM options 设置为:-Dspark.master=local
    设置程序输入参数,Program arguments: localhost:9092 test 3 5
具体信息如下
IDEA中运行KafkaWordCount程序-LMLPHP
    (2)KafkaWordCount
    配置如下:
    IDEA中运行KafkaWordCount程序-LMLPHP
3,先运行KafkaWordCountProducer,再运行KafkaWordCount,在KafkaWordCount的输出窗口中可以看到如下两个情况:
IDEA中运行KafkaWordCount程序-LMLPHP
IDEA中运行KafkaWordCount程序-LMLPHP
05-04 03:03