whyczh
2021-09-08 8c51c3807befed873a7ab86c0e1e52dd189a8b3f
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
package com.whyc.properties;
 
import lombok.extern.log4j.Log4j2;
import org.springframework.util.StringUtils;
 
/**
 * @Description 读取Properties的工具类
 */
@Log4j2
public class PropertiesUtil {
 
    public static LinkProperties propertiesShiro = new LinkProperties();
 
    /**
     * 读取properties配置文件信息
     */
    static {
        /*String sysName = System.getProperty("sys.name");
        if (StringUtils.isEmpty(sysName)) {
            sysName = "application.properties";
        } else {
            sysName += ".properties";
        }*/
        try {
            propertiesShiro.load(PropertiesUtil.class.getClassLoader()
                    .getResourceAsStream("config/authentication.properties"));
        } catch (Exception e) {
            log.warn("资源路径中不存在authentication.properties权限文件,忽略读取!");
        }
    }
 
    /**
     * 根据key得到value的值
     */
    public static String getShiroValue(String key) {
        return propertiesShiro.getProperty(key);
    }
 
}