在学习 SpringBoot + Swagger 2 项目整合时,在 SwaggerConfig 上面加上了 @EnableWebMvc 注解,在启用该注解后,访问页面时 /resources/static/** 的资源被屏蔽掉了,无法访问。
在去掉 @EnableWebMvc 注解后,访问正常。
对于这一点,请问各位大佬,出现这个情况的原因是什么?//@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages = {"com.laiyy.springquartz"})
@Configuration
public class SwaggerConfig {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
.select().apis(RequestHandlerSelectors.basePackage("com.laiyy.springquartz.controller"))
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
} private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Spring-Quartz 定时任务调度")
.version("1.0").build();
}}
在去掉 @EnableWebMvc 注解后,访问正常。
对于这一点,请问各位大佬,出现这个情况的原因是什么?//@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages = {"com.laiyy.springquartz"})
@Configuration
public class SwaggerConfig {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
.select().apis(RequestHandlerSelectors.basePackage("com.laiyy.springquartz.controller"))
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
} private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Spring-Quartz 定时任务调度")
.version("1.0").build();
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货