配置
配置依赖
!!!!!一定要注意spring-boot-starter的版本,太高了,启动项目会报错!!!!!
使用2.3.4.RELEASE的spring-boot-starter 可以配合2.9.2版本的swagger
在pom文件中添加swagger需要的依赖。。
<!--swagger 核心依赖-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<!--swagger ui 接口文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
添加注解
如果swagger配置文件没有设置在当前Package下,需要在启动类上添加扫描注解,扫描的路径要包含到配置文件的路径上。
/*未来能扫描其它微服务的模块,扫描的范围大一些*/
@ComponentScan({"com.atguigu.srb"})