JedisPropertiesConfiguration.java 875 B

123456789101112131415161718192021222324252627282930313233343536
  1. package com.kmall.common.utils.redis;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.stereotype.Component;
  6. /**
  7. * @author Scott Chen
  8. * @since 1.0
  9. * 2018-09-27
  10. */
  11. @Component
  12. public class JedisPropertiesConfiguration {
  13. private static final String PROD = "prod";
  14. private static final String DEV = "dev";
  15. @Value("${redis.env}")
  16. private String evn = DEV;
  17. @Autowired
  18. private JedisProdProperties jedisProdProperties;
  19. @Autowired
  20. private JedisDevProperties jedisDevProperties;
  21. @Bean
  22. public JedisProperties jedisProperties(){
  23. if (evn.equalsIgnoreCase(PROD)) {
  24. return jedisProdProperties;
  25. }else {
  26. return jedisDevProperties;
  27. }
  28. }
  29. }