RESTEasy:找不到内容类型应用程序/json 类型的编写器 [英] RESTEasy: Could not find writer for content-type application/json type

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

问题描述

我有一个安静的服务(post),它使用(application/json)和产生(application/json).此服务的单个参数是一个带注释的 java 对象.

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.

我正在使用 org.jboss.resteasy.client.ClientRequest 将请求发送到服务.但是,我在客户端和异常中收到此异常:

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:

找不到内容类型应用程序/json 类型的编写器.

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

这是否意味着我缺少一些库 jar 或者我必须为 application/json 编写自己的编写器?

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

我使用的是resteasy 2.3.3.Final

I am using resteasy 2.3.3.Final

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

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>

推荐答案

<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>

这就够了.

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

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