MessageBodyReader not found for media type=application/json

后端 未结 8 1608
一生所求
一生所求 2020-12-15 17:10

I have wrote a JAX-RS server and client both use Jersey. I want to sent a collection of my entities to client and I made this steps:

  1. Made entity extends Serial
相关标签:
8条回答
  • 2020-12-15 17:41

    Check if you are registering the media type for JSON support. Do you have jersey-media-moxy on your class-path? If not, add this dependency to your pom.xml, please check your jersey version, in this example I'm using Jersey 2 (2.24)

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>2.24</version>
        </dependency>
    
    0 讨论(0)
  • 2020-12-15 17:42

    You can use jersey json library:

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.22</version>
    </dependency>
    

    Or genson:

    <dependency>
        <groupId>com.owlike</groupId>
        <artifactId>genson</artifactId>
        <version>1.3</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题