Spring Boot Disable /error mapping
Attributes should be specified via @SpringBootApplication. Example in Kotlin:
@SpringBootApplication(exclude = [ErrorMvcAutoConfiguration::class])
class SpringBootLauncher {
You can disable the ErrorMvcAutoConfiguration :
@SpringBootApplication
@EnableAutoConfiguration(exclude = {ErrorMvcAutoConfiguration.class})
public class SpringBootLauncher {
Or through Spring Boot's application.yml/properties:
spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
If this is not an option for you, you may also extend Spring's ErrorController with your own implementation:
@RestController
public class MyErrorController implements ErrorController {
private static final String ERROR_MAPPING = "/error";
@RequestMapping(value = ERROR_MAPPING)
public ResponseEntity<String> error() {
return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
}
@Override
public String getErrorPath() {
return ERROR_MAPPING;
}
Note: Use one of the above techniques (disabled auto-configuration or implement the error-controller). Both together will not work, as mentioned in the comments.