Python 官方文档:入门教程 => 点击学习
swagger 提供了一个全新的维护 api 文档的方式,有4大优点: 自动生成文档:只需要少量的注解,Swagger 就可以根据代码自动生成 API 文档,很好的保证了文
swagger 提供了一个全新的维护 api 文档的方式,有4大优点:
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!--swagger-ui-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
#表示是否开启 Swagger,一般线上环境是关闭的
spring.swagger2.enabled=true
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Value(value = "${spring.swagger2.enabled}")
private Boolean swaggerEnabled;
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.enable(swaggerEnabled)
.select()
.apis(RequestHandlerSelectors.basePackage("com.swagger.boot"))//包名代表需要生成接口文档的目录包。
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("接口文档")
.description(" Spring Boot")
.version("1.0")
.build();
}
}
以上就是SpringBoot集成swagger实现方式的详细内容,更多关于Springboot集成swagger的资料请关注编程网其它相关文章!
--结束END--
本文标题: Springboot集成swagger实现方式
本文链接: https://www.lsjlt.com/news/134170.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0