springboot在线文档编辑
时间: 2023-06-28 20:05:43 浏览: 63
可以使用Swagger Editor来编辑Spring Boot的在线文档。
步骤如下:
1. 在pom.xml中添加Swagger依赖:
```xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
```
2. 在Spring Boot主类上添加注解@EnableSwagger2:
```java
@SpringBootApplication
@EnableSwagger2
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```
3. 编写接口文档注释,例如:
```java
@RestController
@RequestMapping("/api")
@Api(value = "API接口", tags = "API接口")
public class ApiController {
@GetMapping("/hello")
@ApiOperation(value = "Hello接口", notes = "返回Hello字符串")
public String hello() {
return "Hello";
}
}
```
4. 访问http://localhost:8080/swagger-ui.html即可进入Swagger UI在线文档编辑页面。
在页面中,你可以查看和编辑已经生成的API文档,也可以添加新的API文档。编辑完毕后,可以将文档导出为JSON或YAML格式。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)