Swagger的使用
1.首先引入swagger,对应maven坐标
<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>
2.启动swagger配置
注:我使用的使springboot
1.新建swagger配置类,在类上添加注解@Configuration和@EnableSwagger2
@Configuration
@EnableSwagger2
public class SwaggerConfig {
}
3.添加controlle方法
@RestController
@RequestMapping("/hello")
public class HelloController {
@RequestMapping("/sayHello")
public String sayHello(String para){
return "你好"+para;
}
}
4.启动服务
1.访问http://localhost:8080/swagger-ui.html
可以查看当前swagger支持的http方法.