2017-02-21 30 views
0

/刷新端點加入,暴露,我可以直接調用,但它通過HTTP方法個頭不avaialble?方法:頭/刷新返回500

2017年2月21日15:00:08.913 INFO [- ,,,] 4597 --- [主要] osbaemvc.EndpointHandlerMapping:映射「{[/刷新|| /refresh.json],methods = [POST]}」到公共java.lang.Object中org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke()

例外:

org.springframework.web.HttpRequestMethodNotSupportedException:請求方法 'HEAD' 不在org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:20

支持
+0

映射日誌顯示'/ refresh'在'POST'而不是'HEAD'下注冊。你能提供一個關於你如何公開這個端點的代碼片段嗎? – Edd

+0

這是一個執行器端點,由軟件庫內部暴露。 – HODEH

回答

1

我認爲這個問題只發生在你的微服務有@RestController

正如我所看到的,在這裏你是在微服務的差異處理與@RestController

2017-02-22 13:54:38.382 **ERROR** [micro-service-1,e9a053f5ffa72714,3980777f97a147f9,true] 10956 --- [http-nio-auto-3-exec-1] c.s.e.c.e.DefaultExceptionHandler 
: ErrorResponse [errorCode=90000, description=Request method 'HEAD' not supported, correlationId=e9a053f5ffa72714, externalErrorCode=null, additionalProperties={}] 

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'HEAD' not supported 
    at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:207) 
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:374) 
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:314) 

... 

在這裏,你是一個又一個,但在這種情況下,有沒有@RestController

2017-02-22 15:14:49.795 **WARN** [micro-service-2,897590499c7c776c, 
74a8108edccafb5e,true] 27623 --- [http-nio-auto-2-exec-5] 
o.s.web.servlet.PageNotFound  : Request method 'HEAD' not supported 
0

弗蘭謝謝,你是對的,解決這個問題的,因爲班裏有一個@ExceptionHandler(Exception.class),它通過返回500處理未指定的異常,並認爲它作爲內部服務器錯誤。在建議中顯式地將HttpRequestMethodNotSupportedException定義爲@ExceptionHandler,並且使用Spring引導管理員期望的默認執行器JSON響應(405)來處理它,一切都是正常的。