CXF:警告:找不到消息类编写器的响应类ArrayList [英] CXF: WARNING: No message body writer has been found for response class ArrayList
问题描述
我遇到以下错误:
WARNING: No message body writer has been found for response class ArrayList.
在以下代码上:
@GET
@Consumes("application/json")
public List getBridges() {
return new ArrayList(bridges);
}
我知道CXF可以处理这种情况,因为我以前已经做过-在后台定义了CXF和相关Maven工件的平台(即我不知道它是如何完成的。)
I know it's possible for CXF to handle this case because I've done it before - with a platform that defined the CXF and related maven artifacts behind the scenes (i.e. I didn't know how it was done).
问题:如何在不添加XML绑定或其他源代码修改的情况下使CXF支持此操作?
So, the question: how can I get CXF to support this without adding XML bindings or other source code modifications?
请注意以下答案也是如此XML绑定问题,这对我的情况不令人满意:
未找到响应类ArrayList的消息正文编写者
Note the following answer addressed the same problem with XML bindings, which is not satisfactory for my case: No message body writer has been found for response class ArrayList
推荐答案
只是一个简单的缺少Accept标头:
The problem turns out to be a simple missing Accept header:
Accept: application/json
将其添加到请求中即可解决问题。
Adding this to the request resolves the problem.
这篇关于CXF:警告:找不到消息类编写器的响应类ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!