阅读量:2
在CentOS上进行Swagger API管理,可参考以下步骤:
安装环境
若使用Java语言开发,需安装Java和Maven,命令为:
sudo yum install -y java-1.8.0-openjdk-devel maven
搭建Swagger
以Spring Boot项目为例,添加Swagger依赖到pom.xml:
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger2artifactId>
<version>2.9.2version>
dependency>
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger-uiartifactId>
<version>2.9.2version>
dependency>
配置Swagger
创建SwaggerConfig类:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
生成文档
在代码中使用Swagger注解,如@Api、@ApiOperation等描述API,启动应用后,访问http://localhost:8080/swagger-ui.html可查看文档。
以上就是关于“centos swagger API管理”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm