org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler#setMessageReaders ( )源码实例Demo

下面列出了org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler#setMessageReaders ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: JetfireCloud   文件: ExceptionAutoConfiguration.java
@Bean
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    DefaultErrorWebExceptionHandler exceptionHandler = new CustomErrorWebExceptionHandler(
            errorAttributes, this.resourceProperties,
            this.serverProperties.getError(), this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
源代码2 项目: SpringCloud   文件: ExceptionAutoConfiguration.java
@Bean
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    DefaultErrorWebExceptionHandler exceptionHandler = new CustomErrorWebExceptionHandler(
            errorAttributes, this.resourceProperties,
            this.serverProperties.getError(), this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
private DefaultErrorWebExceptionHandler errorHandler(GenericApplicationContext context) {
	context.registerBean(ErrorAttributes.class, () -> new DefaultErrorAttributes());
	context.registerBean(ErrorProperties.class, () -> new ErrorProperties());
	context.registerBean(ResourceProperties.class, () -> new ResourceProperties());
	DefaultErrorWebExceptionHandler handler = new DefaultErrorWebExceptionHandler(
			context.getBean(ErrorAttributes.class), context.getBean(ResourceProperties.class),
			context.getBean(ErrorProperties.class), context);
	ServerCodecConfigurer codecs = ServerCodecConfigurer.create();
	handler.setMessageWriters(codecs.getWriters());
	handler.setMessageReaders(codecs.getReaders());
	return handler;
}