springsession 实现session 共享

 首先加入依赖
1
2 <dependency> 3 <groupId>org.springframework.session</groupId> 4 <artifactId>spring-session</artifactId> 5 </dependency> 6 <dependency> 7 <groupId>org.springframework.boot</groupId> 8 <artifactId>spring-boot-starter-redis</artifactId> 9 </dependency>

其次:application.properties

#server server.port=9090 server.address=localhost #redis spring.redis.host=192.168.1.10 spring.redis.port=6379

 

插入代码:

@Configuration @EnableRedisHttpSession
public class RedisSessionConfig { @Bean public static ConfigureRedisAction configureRedisAction() { return ConfigureRedisAction.NO_OP; } }

不然会报错:
  error creating bean with name enablerediskeyspacenotificationsinitializer
在Linus中  输入命令  redis-cli config set notify-keyspace-events Egx 来开启开启:notify-keyspace-events Egx


具体内容请参考:http://www.cnblogs.com/mengmeng89012/p/5519698.html


 Redis从3.2开始增强安全管理,若是redis没有设置密码,那么redis客户端只能从本地进行访问,若是是从其余机器链接过来访问的,就会报错html

我这边没有设置密码 , 因此须关闭保护模式



  最终结果:
 
  
相关文章
相关标签/搜索