Browse Source

swagger控制

fanxw 1 year ago
parent
commit
03897287a2

+ 2 - 0
src/main/java/com/chinaitop/depot/SwaggerConfig.java

@@ -1,6 +1,7 @@
1 1
 package com.chinaitop.depot;
2 2
 
3 3
 import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4 5
 import org.springframework.context.annotation.Bean;
5 6
 import org.springframework.context.annotation.Configuration;
6 7
 
@@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
14 15
 
15 16
 @Configuration
16 17
 @EnableSwagger2
18
+@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
17 19
 public class SwaggerConfig {
18 20
 
19 21
 	@Value("${eureka.instance.hostname}")

+ 4 - 0
src/main/resources/bootstrap.yml

@@ -3,6 +3,10 @@ server:
3 3
   tomcat:
4 4
     uri-encoding: utf-8
5 5
 
6
+#是否开启swaggeer? true开启,false关闭,生产环境要求关闭
7
+swagger:
8
+  enable: true
9
+
6 10
 # 注册中心配置
7 11
 eureka:
8 12
   client: