[Swagger2]配置Swagger
Posted 唐火
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Swagger2]配置Swagger相关的知识,希望对你有一定的参考价值。
配置Swaggr
1、Swagger实例Bean是Docket,所以通过配置Docket实例来配置Swaggger。
package com.xxxx.swagger2.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import static springfox.documentation.service.ApiInfo.DEFAULT_CONTACT;
@Configuration
// 开启Swagger2
@EnableSwagger2
public class SwaggerConfig
// 配置了Swagger的Docket的bean实例
@Bean
public Docket docket()
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo());
// 配置Swagger信息 = apiInfo()
private ApiInfo apiInfo()
Contact contact = new Contact("firetang","http://wwww.baidu.com","123132@qq.com");
return new ApiInfo("firetangApidocument",
"the author is very cool",
"1.0",
"http://www.baidu.com",
contact,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList<VendorExtension>());
测试
以上是关于[Swagger2]配置Swagger的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot+Security+Swagger2配置