如何映射spring mvc被动异常建议

时间:2018-06-07 18:49:48

标签: spring spring-mvc spring-webflux

如何实施针对被动错误的自定义建议? 与上面的情况一样,它将返回200,但应该是500或其他自定义错误。

@GetMapping("/error")
public Completable completableDaoError() {
    return Completable.error(new Exception());
}

搜索文档时,我发现了WebExceptionHandler和ResponseStatusExceptionHandler(默认实现),但是我无法在我的on上进行映射。

在搜索中,他们只使用地图:

@Component 
@Order(-2)
class RestWebExceptionHandler implements WebExceptionHandler {
}

但这不起作用。 我怎么能在春天的mvc做这个?我没有使用spring-boot只是web-mvc和webflux。

0 个答案:

没有答案