首先加入依賴
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
插入代碼:error creating bean with name enablerediskeyspacenotificationsinitializer
@Configuration @EnableRedisHttpSession public class RedisSessionConfig { @Bean public static ConfigureRedisAction configureRedisAction() { return ConfigureRedisAction.NO_OP; } }
不然會報錯:
在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
我這邊沒有設置密碼 , 因此須關閉保護模式