Spring Boot with Spring Data Rest - how to use a custom error handler. Created an error controller I tried to skip the default error handler by using following code. Why it is not working!
@Configuration
@EnableJpaRepositories
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration(exclude = { BasicErrorController.class })
@EnableMetrics
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
.....................
.....................
and error controller as below
@Component
@RestController
@RequestMapping(value = "/error")
public class CustomErrorController extends BasicErrorController {
public CustomErrorController(ErrorAttributes errorAttributes) {
super(errorAttributes);
// TODO Auto-generated constructor stub
}
private static final String PATH = "/error";
@RequestMapping(value = PATH)
public String error() {
return "Error handling";
}
@Override
public String getErrorPath() {
return PATH;
}
}