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()

猜你喜欢

转载自blog.csdn.net/God__is__a__girl/article/details/82964039