SpringSession

pom.xml

  1. <dependency>
  2. <groupId>org.springframework.session</groupId>
  3. <artifactId>spring-session-data-redis</artifactId>
  4. </dependency>
  1. SessionConfiguration.java
  1. @Configuration
  2. @EnableRedisHttpSession
  3. public class SessionConfiguration {
  4. /**
  5. * SpringSecurity,序列化
  6. */
  7. @Bean(name = "springSessionDefaultRedisSerializer")
  8. public RedisSerializer springSessionDefaultRedisSerializer() {
  9. ObjectMapper objectMapper = new ObjectMapper();
  10. objectMapper.registerModules(SecurityJackson2Modules.getModules(getClass().getClassLoader()));
  11. return new GenericJackson2JsonRedisSerializer(objectMapper);
  12. }
  13. /**
  14. * other
  15. */
  16. @Bean(name = "springSessionDefaultRedisSerializer")
  17. public RedisSerializer springSessionDefaultRedisSerializer() {
  18. return RedisSerializer.json();
  19. }
  20. }