Explorar el Código

swagger控制

fanxw hace 1 año
padre
commit
17f4882be7
Se han modificado 2 ficheros con 8 adiciones y 2 borrados
  1. 3 1
      src/main/java/com/SwaggerConfig.java
  2. 5 1
      src/main/resources/bootstrap.yml

+ 3 - 1
src/main/java/com/SwaggerConfig.java

@@ -1,6 +1,7 @@
1
 package com;
1
 package com;
2
 
2
 
3
 import org.springframework.beans.factory.annotation.Value;
3
 import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4
 import org.springframework.context.annotation.Bean;
5
 import org.springframework.context.annotation.Bean;
5
 import org.springframework.context.annotation.Configuration;
6
 import org.springframework.context.annotation.Configuration;
6
 
7
 
@@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
14
 
15
 
15
 @Configuration
16
 @Configuration
16
 @EnableSwagger2
17
 @EnableSwagger2
18
+@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
17
 public class SwaggerConfig {
19
 public class SwaggerConfig {
18
 
20
 
19
 	@Value("${eureka.instance.hostname}")
21
 	@Value("${eureka.instance.hostname}")
@@ -33,7 +35,7 @@ public class SwaggerConfig {
33
         return new ApiInfoBuilder()
35
         return new ApiInfoBuilder()
34
                 .title("智能粮库管理平台api文档")
36
                 .title("智能粮库管理平台api文档")
35
                 .description("智能仓库")
37
                 .description("智能仓库")
36
-                .termsOfServiceUrl("http://localhost:9001")
38
+                .termsOfServiceUrl(url)
37
                 .version("1.0")
39
                 .version("1.0")
38
                 .build();
40
                 .build();
39
     }
41
     }

+ 5 - 1
src/main/resources/bootstrap.yml

@@ -36,6 +36,10 @@ management:
36
   server:
36
   server:
37
     port: -1
37
     port: -1
38
 
38
 
39
+#是否开启swaggeer? true开启,false关闭,生产环境要求关闭
40
+swagger:
41
+  enable: true
42
+
39
 spring:
43
 spring:
40
   application:
44
   application:
41
     name: depot-intelligent
45
     name: depot-intelligent
@@ -73,4 +77,4 @@ spring:
73
     serialization:
77
     serialization:
74
       FAIL_ON_EMPTY_BEANS: false
78
       FAIL_ON_EMPTY_BEANS: false
75
 web:
79
 web:
76
-  upload-path: /home/depot/depot-web/apache-tomcat-8.0.53/webapps/ROOT/WEB-INF/classes/static
80
+  upload-path: /home/depot/depot-web/depot-file