RESTEasy:找不到内容类型application / json类型的writer [英] RESTEasy: Could not find writer for content-type application/json type

查看:162
本文介绍了RESTEasy:找不到内容类型application / json类型的writer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用(application / json)并生成(application / json)的restful服务(post)。此服务的单个参数是带注释的java对象。



我正在使用org.jboss.resteasy.client.ClientRequest将请求发送到服务。但是,我在客户端获得此异常并且异常:



无法找到内容类型application / json类型的writer。



这是否意味着我缺少一些图书馆罐子,或者我必须为application / json编写自己的编写器?



我正在使用resteasy 2.3.3.Final



以下是我添加到我的pom中的各种依赖项,我认为可能是相关的:

 < dependency> 
< groupId> org.jboss.resteasy< / groupId>
< artifactId> resteasy-jaxrs< / artifactId>
< version> 2.3.3.Final< / version>
< / dependency>

<依赖>
< groupId> com.fasterxml.jackson.jaxrs< / groupId>
< artifactId> jackson-jaxrs-json-provider< / artifactId>
< version> 2.0.5< / version>
< / dependency>

<依赖>
< groupId> org.jboss.resteasy< / groupId>
< artifactId> resteasy-jaxb-provider< / artifactId>
< version> 2.3.4.Final< / version>
< / dependency>

<依赖>
< groupId> org.jboss.resteasy< / groupId>
< artifactId> resteasy-jackson-provider< / artifactId>
< version> 2.3.4.Final< / version>
< / dependency>

<依赖>
< groupId> org.codehaus.jackson< / groupId>
< artifactId> jackson-core-asl< / artifactId>
< version> 1.3.0< / version>
< / dependency>

<依赖>
< groupId> org.codehaus.jackson< / groupId>
< artifactId> jackson-mapper-asl< / artifactId>
< version> 1.3.0< / version>
< / dependency>

Matt

解决方案

 <依赖性> 
< groupId> org.codehaus.jackson< / groupId>
< artifactId> jackson-mapper-asl< / artifactId>
< version> $ {jackson-mapper-asl.version}< / version>
< scope>运行时< / scope>
< / dependency>

<依赖>
< groupId> javax.xml.bind< / groupId>
< artifactId> jaxb-api< / artifactId>
< version> $ {jaxb-api.version}< / version>
< scope>运行时< / scope>
< / dependency>

这已经足够了。



请参阅此处: http: //howtodoinjava.com/2012/12/15/how-to-write-restful-webservices-using-spring-3-mvc/


I have a restful service (post) that consumes (application/json) and produces (application/json). The single param for this service is an annotated java object.

I am using org.jboss.resteasy.client.ClientRequest to send the request to the service. However, I am getting this exception in the client end and the exception:

could not find writer for content-type application/json type.

Does this mean that I am missing some library jars or I have to write my own writer for application/json?

I am using resteasy 2.3.3.Final

Here are various dependencies I added to my pom that I think are probably related:

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>2.3.3.Final</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-json-provider</artifactId>
        <version>2.0.5</version>
    </dependency>

    <dependency>
       <groupId>org.jboss.resteasy</groupId>
       <artifactId>resteasy-jaxb-provider</artifactId>
       <version>2.3.4.Final</version>
    </dependency>

    <dependency>
       <groupId>org.jboss.resteasy</groupId>
       <artifactId>resteasy-jackson-provider</artifactId>
       <version>2.3.4.Final</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.3.0</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.3.0</version>
    </dependency>

Matt

解决方案

<dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>${jackson-mapper-asl.version}</version>
      <scope>runtime</scope>
   </dependency>

   <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>${jaxb-api.version}</version>
      <scope>runtime</scope>
   </dependency>

This is just more than enough.

Refer here: http://howtodoinjava.com/2012/12/15/how-to-write-restful-webservices-using-spring-3-mvc/

这篇关于RESTEasy:找不到内容类型application / json类型的writer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆