我有一个休息应用程序,我使用resteasy和jaxb来生成json输出
@GET
@Produces({MediaType.APPLICATION_JSON})
@Path("/data")
public MyResponse getData {
return new MyResponse("my response"); // Just stubbing this
}
@XmlRootElement(name = "response")
@JsonInclude(Include.NON_NULL)
public class MyResponse {
private String data;
public MyResponse(String data) {
this.data = data;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
我没有使用web.xml,而是创建了一个RestApplication,它扩展了Application并覆盖了getSingletons和getClasses方法。
现在我不确定我需要添加哪些jaxb提供程序类来实现上述工作,我的意思是执行json序列化。
我收到以下错误
Could not find MessageBodyWriter for response object of type:MyResponse of media type: application/json
你能让我知道我需要手动添加哪些类(提供者)才能使其工作吗?