Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法,参数和模型紧密集成到服务器端的代码,允许API来始终保持同步。主要用于接口文档的在线生成以及测试。
-
添加依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
-
添加启用注解
@SpringBootApplication @EnableOpenApi //开启Api public class BootDemoApplication { public static void main(String[] args) { SpringApplication.run(BootDemoApplication.class, args); }
}
-
创建配置文件
@Configuration public class Swagger3Config { @Bean