1.新建一个SpringBoot-web项目

2.导入相关jar包

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>

3.编写一个Helloworld

4.配置Swagger==》config

@Configuration
@EnableSwagger2 //开启Swagger2
public class SwaggerConfig {

}
使用注解@EnableSwagger2 //开启Swagger2
需要jar包
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.2.2</version>
</dependency>

5.测试运行:http://localhost:8080/swagger-ui.html