RedisConfig.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright 2002-2013 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package sample.config;
  17. import org.springframework.context.annotation.Bean;
  18. import org.springframework.context.annotation.Configuration;
  19. import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
  20. import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
  21. /**
  22. * @author Rob Winch
  23. */
  24. @Configuration
  25. @EnableRedisHttpSession
  26. public class RedisConfig {
  27. @Bean
  28. public JedisConnectionFactory connectionFactory(RedisConnectionProperties conn) throws Exception {
  29. JedisConnectionFactory factory = new JedisConnectionFactory();
  30. factory.setPort(conn.getPort());
  31. return factory;
  32. }
  33. }