parent
0fe715ca6d
commit
bdd9b218a1
@ -0,0 +1,37 @@
|
|||||||
|
package com.dsideal.Config;
|
||||||
|
|
||||||
|
import com.jfinal.kit.Prop;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class PropKit {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PropKit.class);
|
||||||
|
|
||||||
|
public static String getEnvPrefix() {
|
||||||
|
String myEnvVar = System.getenv("WORKING_ENV");
|
||||||
|
if (myEnvVar == null) {
|
||||||
|
myEnvVar = "dev";
|
||||||
|
}
|
||||||
|
return myEnvVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Prop prop;
|
||||||
|
public static String configFile;
|
||||||
|
|
||||||
|
static {
|
||||||
|
//加载配置文件
|
||||||
|
configFile = "application_{?}.yaml".replace("{?}", getEnvPrefix());
|
||||||
|
prop = new YamlProp(configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(String key) {
|
||||||
|
if (!prop.containsKey(key)) {
|
||||||
|
throw new RuntimeException("没有找到配置文件" + configFile + "中的键值:" + key);
|
||||||
|
}
|
||||||
|
return prop.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getInt(String key) {
|
||||||
|
return prop.getInt(key);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.dsideal.Res.Plugin;
|
package com.dsideal.Config;
|
||||||
|
|
||||||
import com.jfinal.kit.Prop;
|
import com.jfinal.kit.Prop;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
@ -1,4 +1,4 @@
|
|||||||
package com.dsideal.Base.Plugin;
|
package com.dsideal.Config;
|
||||||
|
|
||||||
import com.jfinal.kit.Prop;
|
import com.jfinal.kit.Prop;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
Loading…
Reference in new issue