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); } }