Unable to infer base url. This is common when using dynamic...錯誤解決辦法

啓動swagger2報錯Unable to infer base url. …

具體錯誤如下
Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. 
The base url is the root of where all the swagger resources are served.
 For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/.
  Please enter the location manually:

2.7及之前的版本好像不會出現這種問題.

原因 :

Swagger2 版本 落後與 身份驗證版本 (SpringSecurity),更新到Springfox 2.8.0後,/swagger-resources/**路由不會被Authorization標頭調用

解決方法 :

在身份認證(SpringSecurity)的時候添加
.antMatchers("/swagger-resources/**").permitAll()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章