How to disable ErrorPageFilter in Spring Boot?

The simpliest way to disable ErrorPageFilter is:

@SpringBootApplication
public class App extends SpringBootServletInitializer {

public App() {
    super();
    setRegisterErrorPageFilter(false); // <- this one
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(App.class);
}

public static void main(String[] args) {
    SpringApplication.run(App.class, args);
}

To disable the ErrorPageFilter in Spring Boot (tested with 1.3.0.RELEASE), add the following beans to your Spring configuration:

@Bean
public ErrorPageFilter errorPageFilter() {
    return new ErrorPageFilter();
}

@Bean
public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(filter);
    filterRegistrationBean.setEnabled(false);
    return filterRegistrationBean;
}

    @SpringBootApplication
public class MyApplication extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        //set register error pagefilter false
        setRegisterErrorPageFilter(false);

        builder.sources(MyApplication.class);
        return builder;
    }

}