解决Swagger-ui页面打开显示循环错误:
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:
1.swagger类保证写了注解
@Configuration
@EnableSwagger2 // 开启swagger2
出现原因:
拦截器或过滤器拦截了swagger自带的一些方法
解决方法:
1.1:
拦截器中对下列方法进行放行
|| uri.endsWith(“doc.html”)
|| uri.endsWith(“swagger-ui.html”)
|| uri.contains("/swagger-resources")
|| uri.endsWith(“api-docs”)
为了更加美化与实际项目开发的效率,我们一般:
通过http://ip:端口/doc.html,直观使用
类上:
@Api(tags=“菜单名”)
方法上:
@AutoLog(value = “方法备注(方法名)”)
@ApiOperation(value=“备注”, notes=“备注”)