如果评论builder.setBolt然后它正确运行。请告诉我出错的地方
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("words", new TestWordSpout(), 3);
//Calling setBolt
builder.setBolt("exc", new ExclaimBolt(),3)
.allGrouping("words");
Config conf = new Config();
conf.setDebug(false);
//conf.setNumWorkers(2);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
答案 0 :(得分:1)
没有在Spout中声明输出字段。 声明它工作正常后。
代码示例(在你的螺栓类中):
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("msg"));//based on u project
}