<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.2</version>
</dependency>
@Configuration
@EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class Swagger2Config {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
Docket docket =
new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
// 分组名称
.groupName("管理系统_1.0")
.select()
// 这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.project.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 文档标题
.title("若芽API系统")
// 文档描述
.description("API文档自动生成示例")
// 版本号
.version("1.0")
.build();
}
}