knife4j
1.导入maven依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
2.导入knife4j配置类
@Configuration
@EnableSwagger2
public class Knife4jConfig {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.title("瑞吉外卖")
.description("瑞吉外卖")
.termsOfServiceUrl("http://www.xx.com/")
.contact(new Contact("mrs","localhost","2314028487"))
.version("1.0")
.build())
//分组名称
.groupName("v1.1版本")
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.hxut.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
3.设置静态资源
//放行knife4j
registry.addResourceHandler("doc.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
过滤器放行: