JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

后端 未结 2 2064
自闭症患者
自闭症患者 2021-01-04 00:03

I wanted to write a small and simple REST service using Spring Boot. Here is the REST service code:

@Async
@RequestMapping(value = \"/getuser\", method = POS         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 00:14

    Perhaps you are trying to send a request with JSON text in its body from a Postman client or something similar like this:

    {
     "userId": 3
    }
    

    This cannot be deserialized by Jackson since this is not an Integer (it seems to be, but it isn't). An Integer object from java.lang Integer is a little more complex.

    For your Postman request to work, simply put (without curly braces { }):

    3
    

提交回复
热议问题