Summary article of this issues / 19844
From Spring Boot 2.3.0 or later GetErrorPath of ʻErrorController` used for error handling such as 404 has been deprecated.
ErrorController.java
/**
* The return value from this method is not used; the property `server.error.path`
* must be set to override the default error page path.
* @return the error path
* @deprecated since 2.3.0 in favor of setting the property `server.error.path`
*/
@Deprecated
String getErrorPath();
I get a warning at compile time.
As described in Javadoc in the first place, there is no particular point in overriding the corresponding method.
(Because the setting contents of server.error.path
are valid)
ErrorController implementation class
@Override
public String getErrorPath() {
return null;
}
If you are worried about the warning, add @Deprecated
to remove the warning.
ErrorController implementation class
@Deprecated
@Override
public String getErrorPath() {
return null;
}
Note that the default BasicErrorController
will be enabled if ErrorController is not implemented.
ErrorMvcAutoConfiguration.java
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController basicErrorController(ErrorAttributes errorAttributes,
ObjectProvider<ErrorViewResolver> errorViewResolvers) {
return new BasicErrorController(errorAttributes, this.serverProperties.getError(),
errorViewResolvers.orderedStream().collect(Collectors.toList()));
}
Recommended Posts