Commit 2a7704a8 by 阳浪

SwaggerConfig

parent c04b0b82
package com.yizhi.application.config; package com.yizhi.application.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -18,6 +19,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -18,6 +19,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2 @EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter{ public class SwaggerConfig extends WebMvcConfigurerAdapter{
@Value("${swagger.enabled}")
private boolean swaggerEnabled;
/** /**
* 这个地方要重新注入一下资源文件,不然不会注入资源的,也没有注入requestHandlerMappping,相当于xml配置的 * 这个地方要重新注入一下资源文件,不然不会注入资源的,也没有注入requestHandlerMappping,相当于xml配置的
* <!--swagger资源配置--> * <!--swagger资源配置-->
...@@ -37,7 +40,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter{ ...@@ -37,7 +40,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter{
@Bean @Bean
public Docket createRestApi() { public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2).enable(swaggerEnabled)
.select() .select()
.apis(RequestHandlerSelectors.basePackage("com.yizhi.application")) .apis(RequestHandlerSelectors.basePackage("com.yizhi.application"))
.build() .build()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment