参考链接:https://www.shenmazong.com/blog/1529682926714634240
package com.two.interview.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author 军哥
* @version 1.0
* @description: Knife4jConfiguration
* @date 2022/8/2 16:08
*/
@Configuration
@EnableSwagger2
public class Knife4jConfiguration {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
String groupName="3.X版本";
Docket docket=new Docket(DocumentationType.OAS_30)
.apiInfo(new ApiInfoBuilder()
.title("用户中心 API ")
.description("# 用户中心API")
.termsOfServiceUrl("https://www.shenmazong.com")
.contact(new Contact("亮子说编程","http://yaomaoyang.com","361426201@qq.com"))
.version("3.0")
.build())
//分组名称
.groupName(groupName)
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.two.interview.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
}