在发送 HTTP 请求时需要指定 Accept 头的属性为“application/json”,如下所示:
ProducerTemplate template = context.createProducerTemplate(); template.sendBodyAndHeaders( "http://localhost:8080/myapp/myservice", null, Collections.singletonMap("Accept", "application/json") );
这样,在发送请求时就会带有“application/json”属性的 Accept 头,从而避免因缺少 Accept 头引起的错误。