Spring SessionとRedisを使ってセッションを管理します.
2077 ワード
spring.redis.database=0
spring.redis.host=localhost
spring.redis.password=
spring.redis.pool.max-active=8
spring.redis.pool.max-idle=8
spring.redis.pool.max-wait=-1
spring.redis.pool.min-idle=0
spring.redis.port=6379
スプリングセッションの構成を追加します.spring.session.store-type=redis
最後にテストを行います@RequestMapping("/")
@ResponseBody
String home(HttpSession session) {
session.setAttribute("test", new Date());
return "Hello World!";
}
やはり元々sessionを使う方式です.レコードはredisで確認できます.