ConstantPropertiesUtils.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.ozs.utils;
  2. import org.springframework.beans.factory.InitializingBean;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.stereotype.Component;
  5. //当项目已启动,spring接口,spring加载之后,执行接口一个方法
  6. @Component
  7. public class ConstantPropertiesUtils implements InitializingBean {
  8. //读取配置文件内容
  9. @Value("${aliyun.oss.file.endpoint}")
  10. private String endpoint;
  11. @Value("${aliyun.oss.file.keyid}")
  12. private String keyId;
  13. @Value("${aliyun.oss.file.keysecret}")
  14. private String keySecret;
  15. @Value("${aliyun.oss.file.bucketname}")
  16. private String bucketName;
  17. //定义公开静态常量
  18. public static String END_POINT;
  19. public static String ACCESS_KEY_ID;
  20. public static String ACCESS_KEY_SECRET;
  21. public static String BUCKET_NAME;
  22. @Override
  23. public void afterPropertiesSet() throws Exception {
  24. END_POINT = endpoint;
  25. ACCESS_KEY_ID = keyId;
  26. ACCESS_KEY_SECRET = keySecret;
  27. BUCKET_NAME = bucketName;
  28. }
  29. }