EccsPropertiesConfig.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.kmall.admin.config;
  2. import com.kmall.admin.properties.EccsProperties;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.beans.factory.annotation.Configurable;
  5. import org.springframework.beans.factory.annotation.Value;
  6. import org.springframework.context.annotation.Bean;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.context.annotation.PropertySource;
  9. import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
  10. import org.springframework.core.env.Environment;
  11. import org.springframework.core.env.StandardEnvironment;
  12. /**
  13. * @author zhangchuangbiao
  14. * @version 1.0
  15. * 2021-01-28 15:27
  16. */
  17. @Configuration
  18. @PropertySource("classpath:conf/eccs.properties")
  19. public class EccsPropertiesConfig {
  20. // @Value("${md5Salt}")
  21. private String md5Salt;
  22. // @Value("${requestUrl}")
  23. private String requestUrl;
  24. @Autowired
  25. private Environment environment;
  26. @Bean
  27. public EccsProperties ecsProperties(){
  28. String md5Salt = environment.getProperty("md5Salt");
  29. String requestUrl = environment.getProperty("requestUrl");
  30. EccsProperties eccsProperties = new EccsProperties();
  31. eccsProperties.setMd5Salt(md5Salt);
  32. eccsProperties.setRequestUrl(requestUrl);
  33. return eccsProperties;
  34. }
  35. }