- MERRY CHRISTMAS -
圣诞快乐
Springboot 集成Swagger 2(springfox)
1、集成
导入依赖:
Springfox Swagger2:
<dependency> <groupId>io.springfoxgroupId> <artifactId>springfox-swagger2artifactId> <version>3.0.0version>dependency>
Springfox Swagger UI:
<dependency> <groupId>io.springfoxgroupId> <artifactId>springfox-swagger-uiartifactId> <version>3.0.0version>dependency>
配置swagger:
@Configuration@EnableSwagger2public class SwaggerConfig{}
创建一个以上一个类配置swagger即可。
默认效果:
访问界面:IP:port/swagger-ui.html
2、配置
在以上配置类中添加方法:
//配置swagger的Docket的Bean实例@Beanpublic Docket docket(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(this.apiInfo());}//自定义swagger信息private ApiInfo apiInfo(){
Contact contact = new Contact("name","url","email"); return new ApiInfo("title","description","