在spring springMVC整合swagger2,完成访问swagger-ui.html的时候出现
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:
其实出现这个可能有不少原因:但是最可能的是因为访问swagger-ui.html的时候,swagger-ui.html还会向你的服务器发出4个请求,请求你的相关信息,也就是你的controller包下的controller相关内容,这4个请求报了404所以弹出这个。
大部分人出现这个是因为springMVC的过滤原则设置的是*.do或者是*.xxx其它,但是swagger-ui.html的这4个请求是不带.xxx结尾的,所以最简单解决方案:修改springMVC配置:加一个带/的配置,修改之后可能其它的会冲突了,那也只能你自己去改,自己的项目,毕竟自己最了解。