|
@@ -0,0 +1,53 @@
|
|
|
+package com.kingdee.eas.custom.beisen.utils;
|
|
|
+
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
+
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取配置文件参数值
|
|
|
+ * description: BeisenParamByProperties <br>
|
|
|
+ * date: 2025/7/7 16:03 <br>
|
|
|
+ * author: lhbj <br>
|
|
|
+ * version: 1.0 <br>
|
|
|
+ */
|
|
|
+public class BeisenParamByProperties {
|
|
|
+ private static Logger logger =Logger.getLogger(BeisenParamByProperties.class);
|
|
|
+ private Properties propt = new Properties();//共用参数
|
|
|
+ /**
|
|
|
+ * filePath地址从server开始,例:/server/properties/beisen/beisenConfig.properties
|
|
|
+ * @param filePath
|
|
|
+ */
|
|
|
+ public BeisenParamByProperties(String filePath) throws IOException {
|
|
|
+ this.initConfig(System.getProperty("EAS_HOME") + filePath);
|
|
|
+ }
|
|
|
+ public BeisenParamByProperties() throws IOException {
|
|
|
+ this.initConfig(System.getProperty("EAS_HOME") + BeisenParam.BEISEN_CONFIG_PATH);
|
|
|
+ }
|
|
|
+ public void initConfig(String filePath) throws IOException {
|
|
|
+ try {
|
|
|
+ if(StringUtils.isBlank(filePath)){
|
|
|
+ throw new IOException("filePath参数为空");
|
|
|
+ }
|
|
|
+ this.propt.load(new FileInputStream(filePath));
|
|
|
+ }catch (IOException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("未找到"+filePath+"配置文件。");
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public Map<String,String> getConfig() {
|
|
|
+ Map<String,String> map = Maps.newHashMap();
|
|
|
+ Set<Map.Entry<Object, Object>> set = this.propt.entrySet();
|
|
|
+ for(Map.Entry<Object, Object> entry : set){
|
|
|
+ map.put((String)entry.getKey(),(String)entry.getValue());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|