Swagger 2.10.5 使用方法及问题

由于接手一个项目,用的swagger2.10.5,和其它版本有些不一样,查了好久,因此从头研究学习了一下。参考这篇博客

1,导入依赖项到pom.xml

 

   此时swagger.version默认为2.10.5, 默认引入的为1.5.20将原来默认的1.5.20版本提出,引入新的1.5.21.

  打开swagger时一直出现Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base uril is the root of where all the swagger resources are served.错误,又查了下,web-starter集成的webmvc版本是5.3.20,于是手动在pom.xml中引入2.10.5版本的springfox-spring-webmvc

   果然问题解决。

2, 配置类

  配置类上需要加注释@EnableSwagger2WebMvc  

 

 3,  页面展示

 

  zeng zeng !出现啦!

 

posted @ 2022-12-19 16:31  玻璃公主  阅读(1281)  评论(0编辑  收藏  举报