我尝试以多种方式注册自定义异常映射器:
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ConstraintViolationException> {
@Override
public Response toResponse(ConstraintViolationException exception) {
...
}
}
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ResteasyViolationException> {
@Override
public Response toResponse(ResteasyViolationException exception) {
...
}
}
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ValidationException> {
@Override
public Response toResponse(ValidationException exception) {
...
}
}
但发生的一切都是 ResteasyViolationExceptionMapper 的默认行为。我的自定义 ExceptionMapper 永远不会被调用。我不知道还能尝试什么。