springboot2+knife4j配置记录
1、引入pom
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
2、新增配置类
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.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfiguration {
private final String SWAGGER_SCAN_BASE_PACKAGE =
"com.timevale.epaas.seal.physical.api.controller";
@Bean(value = "dockerBean")
public Docket dockerBean() {
// 指定使用Swagger2规范
Docket docket =
new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
// 分组名称
.groupName("你好")
.select()
// 这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
.paths(PathSelectors.any())
.build();
return docket;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("物理印控")
.description("physical seal online doc")
.termsOfServiceUrl("https://www.esign.cn/")
.contact(new Contact("风清扬", "https://www.esign.cn/", "fengqingyang@tsign.cn"))
.version("1.0")
.build();
}
}
3、使用注解
@Api(tags = "指纹模块")
@ApiOperation(value = "分页查询指纹信息",httpMethod = "GET")
@ApiModel
@ApiModelProperty("指纹id")
正文到此结束
- 本文标签: Spring Boot java
- 版权声明: 本站原创文章,于2023年03月28日由Mars发布,转载请注明出处