Jersey Exception mappers not working when jackson deserialization fails

后端 未结 5 2035
借酒劲吻你
借酒劲吻你 2020-12-29 06:57

I am using Jersey 2.10 with Jackson serialization/deserialization feature in my REST API.

My idea is to make my REST API to always return a standard JSON error resp

5条回答
  •  感动是毒
    2020-12-29 07:33

    I had the same problem and solve overriding the ExceptionMapper. Perfect! One extra thing that I needed to do and were not understanding 100% was how to override the JacksonProvider for my application (I don't know if it was related to Jersey's version that I was using - 2.19). Here's my web.xml part that overrides it:

    
        jersey.config.server.provider.classnames
           
              com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
           
    
    

提交回复
热议问题