我能够找到解决方案。
# Whether a "NoHandlerFoundException" should be thrown if no Handler was found to process a request.spring.mvc.throw-exception-if-no-handler-found=truespring.resources.add-mappings=false
错误处理代码:
@Overrideprotected ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { // custom logic here return handleExceptionInternal(ex, error, getHeaders(), HttpStatus.BAD_REQUEST, request);}


