我正在尝试创建一个平静的平台Web服务。我必须将JSON对象传递给webservice。如何配置项目以使用JSON提供程序和平台安静的Web服务
@POST
@Path("/saveVehicleTrackingData")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String saveVehicleTrackingData(VehicleTracking vehicleTracking) {
return vehicleTracking.toString();
}
,我没有到JSON提供程序添加到我的项目的唯一事情是我加入这个Maven的依赖性:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.5.1</version>
</dependency>
由于this page说:
Due to auto-registration, it should be possible to simply add Maven
dependency (or include jar if using other build systems) and let JAX-RS
implementation discover provider. If this does not work you need to consult
documentation of the JAX-RS implementation for details.
但是自动注册不是工作,我越来越415-不支持的媒体类型尝试访问网络服务时出错。有没有关于如何正确注册json提供者的指南?
非常感谢,将** com.fasterxml.jackson.jaxrs.json **添加到为我工作的参数值中。 – 2015-04-06 08:12:15