[原创]解决swagger2弹窗问题:Unable to infer base url. This is common when using dynamic...

弹窗错误信息:

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: 

各种百度,谷歌.......

后来发现是因为swagger2页面期望接口返回json数据,而实际后端返回的是Xml格式数据,造成前端页面解析数据异常引起的(其实在请求时添加请求头accept,指名需要的数据格式就可以解决这个问题的,不知道swagger2开发人员为什么没这样写),

springboot会默认配置xml消息转换支持,优先级要高于json,

so自定义消息转换器:

抄的springboot的默认配置,只不过把配置xml消息转换的代码去除了,

重启项目完美解决``````~~~~