SpringBoot集成Swagger 引入依赖 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version> </dependency> 编写HelloController,测试确保运行成功! package com.xxxx.swagger2.controller;import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;@RestController public class HelloController {@RequestMapping(value = "/hello")public String hello(){return "hello";}} 要使用Swagger,我们需要编写一个配置类-SwaggerConfig来配置 Swagger @Configuration //配置类 @EnableSwagger2// 开启Swagger2的自动配置 public class SwaggerConfig { } 访问测试 :http://localhost:8080/swagger-ui.html ,可以看到swagger的界面;