Whether the below changes will work fine in spring 5 ?
Please suggest the right way to proceed
Spring 2:
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer()
{
return container ->
{
container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/not-found"));
};
}
spring 5 :
@Bean
public WebServerFactoryCustomizer containerCustomizer()
{
return container ->
{
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/not-found"));
container = factory;
};
}
I referenced the below links,
The equivalent code in Spring Boot 2 is the following:
@Bean
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> webServerFactoryCustomizer() {
return (factory) -> factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/not-found"));
}