Jersey unable to catch any Jackson Exception

前端 未结 2 1597
天命终不由人
天命终不由人 2020-12-17 20:03

For my REST api I\'m using jersey and ExceptionMapper to catch global exceptions. It works well all the exception my app throws but I\'m unable to catch exception thrown by

2条回答
  •  感情败类
    2020-12-17 20:26

    Hi it seems to exits an alternative answer now that does not require to disable Jersey AUTO_DISCOVERY feature.

    Just annotate your own exception mapper with a @Priority(1) annotation. The lower the number, the higher the priority. Since Jackson's own mappers do not have any priority annotation, yours will be executed:

    @Priority(1)
    public class MyJsonMappingExceptionMapper implements ExceptionMapper
    

提交回复
热议问题