1,首先导入一个启动依赖包
3.0 以前需要导入的包有两个,分别是swagger-ui和swagger2,3.0只需要导入一个起步依赖就可以了。
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
2,写一个配置类
创建一个配置类,名字随意定义,本例中定义为:SwaggerConfig.java,以前的版本注解需要使用:@Configuration和@EnableSwagger2, 但是3.0 之后需要的注解变成:@EnableOpenApi和@Configration。
@Configration
@EnableOpenApi
public class SWaggerConfig{
}
3, 访问路径
以前的访问路径是:localhost:8080/swagger-ui.html, 3.0之后的swagger需要改成:localhost:8080/swagger-ui/index.html,他的来源参考新导入的jar包:
路径查看结果:
4,配置设定
其他具体配置设定,请参考其他的教程。
个人推荐:https://www.bilibili.com/video/BV1Y441197Lw