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