ConfigUtil.java
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.bsth.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Properties;
public class ConfigUtil {
private final static Logger log = LoggerFactory.getLogger(ConfigUtil.class);
private static Properties prop = new Properties();
static Tools tools;
static{
tools = new Tools("application.properties");
String active = tools.getValue("spring.profiles.active");
tools = new Tools("application-"+active+".properties");
tools = new Tools("application-"+active+".properties");
load();
}
public static String get(String key){
return tools.getValue(key);
}
/**
* 从全局配置文件从获取数据
* @param key 键
* @return
*/
public static String getProperty(String key) {
return prop.getProperty(key);
}
public static void load() {
try {
prop.load(ConfigUtil.class.getResourceAsStream("/xlnum.properties"));
} catch (IOException e) {
// TODO Auto-generated catch block
log.error("加载lxnum.properties配置文件失败,请检查。。。", e);
}
}
}