Selaa lähdekoodia

ApiUtils读取配置文件修改

chenjun 1 vuosi sitten
vanhempi
commit
b464461389

+ 17 - 7
zjugis-workflow/src/main/java/com/zjugis/z_workflow/base/workflow/ApiUtils.java

@@ -2,6 +2,8 @@ package com.zjugis.z_workflow.base.workflow;
 
 import com.zjugis.framework.workflow.form.YamlConfig;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
 
 /**
  * @Description: Yml配置文件操作类
@@ -10,6 +12,7 @@ import org.apache.commons.lang.StringUtils;
  * @Copyright: 2019浙江万维空间信息技术有限公司
  * @Version: v1.0
  */
+@Configuration
 public class ApiUtils {
 
 	private static String ymlName = "application.yaml";//yml文件名称
@@ -17,6 +20,20 @@ public class ApiUtils {
 	private static String zWorkFlowUrl;
 	private static String zFileManagement;
 
+    @Value("${serviceUrl.z_bussiness_commom}")
+    public void setCommonSystemUrl(String commonSystemUrl2) {
+        commonSystemUrl = commonSystemUrl2;
+    }
+
+    @Value("${serviceUrl.z_workflow}")
+    public void setzWorkFlowUrl(String zWorkFlowUrl2) {
+        zWorkFlowUrl = zWorkFlowUrl2;
+    }
+
+    @Value("${serviceUrl.z_file_management}")
+    public void setzFileManagement(String zFileManagement2) {
+        zFileManagement = zFileManagement2;
+    }
 
 	/**
 	 * 获取Yml配置Value值
@@ -39,22 +56,15 @@ public class ApiUtils {
 	 * @Date 2019/11/26 13:56
 	 **/
 	public static String GetCommonSystemUrl() {
-		if (StringUtils.isBlank(commonSystemUrl)) {
-			commonSystemUrl = GetYmlValue("serviceUrl.z_bussiness_commom");
-		}
 		return commonSystemUrl.endsWith("/") ? commonSystemUrl.substring(0, commonSystemUrl.lastIndexOf("/")) : commonSystemUrl;
 	}
 
 
 	public static String getzWorkFlowUrl() {
-		if (StringUtils.isBlank(zWorkFlowUrl))
-			zWorkFlowUrl = GetYmlValue("serviceUrl.z_workflow");
 		return zWorkFlowUrl.endsWith("/") ? zWorkFlowUrl.substring(0, zWorkFlowUrl.lastIndexOf("/")) : zWorkFlowUrl;
 	}
 
 	public static String getzFileManagement() {
-		if (StringUtils.isBlank(zFileManagement))
-			zFileManagement = GetYmlValue("serviceUrl.z_file_management");
 		return zFileManagement.endsWith("/") ? zFileManagement.substring(0, zFileManagement.lastIndexOf("/")) : zFileManagement;
 	}
 }