fanxw 2 yıl önce
ebeveyn
işleme
b7a8c8e3af

+ 9 - 1
src/main/java/com/chinaitop/depot/SwaggerConfig.java

@@ -1,5 +1,6 @@
1 1
 package com.chinaitop.depot;
2 2
 
3
+import org.springframework.beans.factory.annotation.Value;
3 4
 import org.springframework.context.annotation.Bean;
4 5
 import org.springframework.context.annotation.Configuration;
5 6
 
@@ -14,6 +15,12 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
14 15
 @Configuration
15 16
 @EnableSwagger2
16 17
 public class SwaggerConfig {
18
+	
19
+	@Value("${eureka.instance.ip-address}")
20
+	private String eureka_id;
21
+	
22
+	@Value("${server.port}")
23
+	private String server_port;
17 24
 
18 25
     @Bean
19 26
     public Docket createRestApi() {
@@ -25,10 +32,11 @@ public class SwaggerConfig {
25 32
                 .build();
26 33
     }
27 34
     private ApiInfo apiInfo() {
35
+    	String url = "http://"+eureka_id+":"+server_port;
28 36
         return new ApiInfoBuilder()
29 37
                 .title("智能粮库管理平台api文档")
30 38
                 .description("系统管理")
31
-                .termsOfServiceUrl("http://localhost:8080")
39
+                .termsOfServiceUrl(url.trim())
32 40
                 .version("1.0")
33 41
                 .build();
34 42
     }