PropUtil.java 816 B

123456789101112131415161718192021222324252627282930
  1. package com.sagacloud.utils;
  2. import com.sagacloud.route.InitEnvRoute;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import java.io.IOException;
  6. import java.util.Properties;
  7. /**
  8. * Created by Xiaoyu on 2018/7/10
  9. */
  10. public class PropUtil {
  11. private static final Logger log = LoggerFactory.getLogger(PropUtil.class);
  12. static Properties prop = new Properties();
  13. static {
  14. try {
  15. prop.load(PropUtil.class.getClassLoader().getResourceAsStream("config.properties"));
  16. InitEnvRoute.dataPlatform = prop.getProperty("dataPlatform.baseUrl");
  17. } catch (IOException e) {
  18. e.printStackTrace();
  19. log.error("Load properties failed.");
  20. }
  21. }
  22. public static String getProperty(String key){
  23. return prop.getProperty(key);
  24. }
  25. }