ConfigProperties.java
3.12 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.essa.framework;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Created by weicheng on 2018/10/25.
*/
public class ConfigProperties {
//浏览器名称
private String browserName;
//bpms首页url
private String serverURL;
//buyer首页url
private String buyerURL;
// 数据库驱动名字
private String jdbcName = null;
// 数据库协议地址
private String dbUrl = null;
// 数据库用户名
private String dbUser = null;
// 数据库密码
private String dbPassword = null;
private ConfigProperties() {
}
private static Map<String,ConfigProperties> configPropertiesMap = new HashMap<String,ConfigProperties>();
static {
//读取各个环境的配置项
EnvEnum[] env = EnvEnum.values();
for (EnvEnum envEnum : env) {
try {
ConfigProperties configProperties = new ConfigProperties();
Properties p = new Properties();
InputStream ips = ClassLoader.getSystemResourceAsStream("conf/config_" + envEnum.getCode() +".properties");
p.load(ips);
configProperties.setBrowserName(p.getProperty("browserName"));//使用jframe要注释
configProperties.setBuyerURL(p.getProperty("buyerURL"));
configProperties.setServerURL(p.getProperty("serverURL"));
configProperties.setJdbcName(p.getProperty("jdbc.driver"));
configProperties.setDbUrl(p.getProperty("jdbc.url"));
configProperties.setDbUser(p.getProperty("jdbc.user"));
configProperties.setDbPassword(p.getProperty("jdbc.pwd"));
configPropertiesMap.put(envEnum.getCode(),configProperties);
ips.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static ConfigProperties getConfig(EnvEnum envEnum) {
return configPropertiesMap.get(envEnum.getCode());
}
public String getBrowserName() {
return browserName;
}
public void setBrowserName(String browserName) {
this.browserName = browserName;
}
public String getServerURL() {
return serverURL;
}
public void setServerURL(String serverURL) {
this.serverURL = serverURL;
}
public String getBuyerURL() {
return buyerURL;
}
public void setBuyerURL(String buyerURL) {
this.buyerURL = buyerURL;
}
public String getJdbcName() {
return jdbcName;
}
public void setJdbcName(String jdbcName) {
this.jdbcName = jdbcName;
}
public String getDbUrl() {
return dbUrl;
}
public void setDbUrl(String dbUrl) {
this.dbUrl = dbUrl;
}
public String getDbUser() {
return dbUser;
}
public void setDbUser(String dbUser) {
this.dbUser = dbUser;
}
public String getDbPassword() {
return dbPassword;
}
public void setDbPassword(String dbPassword) {
this.dbPassword = dbPassword;
}
}