package com.tzld.piaoquan.longarticle.utils; import lombok.extern.slf4j.Slf4j; import org.springframework.core.io.ClassPathResource; import java.io.IOException; import java.util.Properties; @Slf4j public class ConfigUtil { private static Properties properties = readProperties("application.properties"); private static Properties readProperties(String... confFile) { final Properties properties = new Properties(); try { for (String path : confFile) { final ClassPathResource resource = new ClassPathResource(path); properties.load(resource.getInputStream()); } } catch (IOException e) { log.error("ConfigUtil readProperties error", e); } return properties; } public static String getConfig(String key) { return properties.getProperty(key); } }