PropertyUtil.java 723 B

1234567891011121314151617181920212223
  1. package com.lemon.lifecenter.common;
  2. import org.springframework.context.ApplicationContext;
  3. public class PropertyUtil {
  4. public static String getProperty(String propertyName) {
  5. return getProperty(propertyName, null);
  6. }
  7. public static String getProperty(String propertyName, String defaultValue) {
  8. String value = defaultValue;
  9. ApplicationContext applicationContext = ApplicationContextServe.getApplicationContext();
  10. if(applicationContext.getEnvironment().getProperty(propertyName) == null) {
  11. } else {
  12. value = applicationContext.getEnvironment().getProperty(propertyName).toString();
  13. }
  14. return value;
  15. }
  16. }