标签:repo rip ack host localhost 测试 简介 boot tor
1.简介
RestFul API文档在线自动生成工具 => API文档与API定义同步更新
直接运行,可以在线测试API接口
2.在项目使用Swagger需要springfox
3.SpringBoot集成Swagger2
在pom.xml中导入依赖
<!-- 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>
4.编写一个Hello过程
package com.kuang.swagger.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "hello";
}
}
5.配置swagger ==》config
config/SwaggerConfig.java
package com.kuang.swagger.config;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableSwagger2 // 开启swagger2
public class SwaggerConfig {
}

6.启动运行
http://localhost:8088/swagger-ui.html

标签:repo rip ack host localhost 测试 简介 boot tor
原文地址:https://www.cnblogs.com/GumpYan/p/14899970.html