在接手一个项目时,为了方便测试要暂停springsession,redis的使用,改用在jvm'中保存。
1.改变session保存方式。
@Configuration
public class SessionConfig {
@Bean
/* public CookieHttpSessionStrategy cookieHttpSessionStrategy() {
DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();
defaultCookieSerializer.setCookieName("JSESSIONID");
CookieHttpSessionStrategy cookieHttpSessionStrategy = new CookieHttpSessionStrategy();
cookieHttpSessionStrategy.setCookieSerializer(defaultCookieSerializer);//重定义cookie name jsessionid
return cookieHttpSessionStrategy;
}*/
public MapSessionRepository mapSessionRepository() {
DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();
defaultCookieSerializer.setCookieName("JSESSIONID");
MapSessionRepository mapSessionRepository = new MapSessionRepository(new ConcurrentHashMap<>());
return mapSessionRepository;
}
}
2.修改配置文件
### session ###
###spring.session.store-type=redis###
#spring.session.store-type=none
注销redis集群配置
.
.
.
.
.
启动!。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
报错,redis pool 连接不上。什么鬼我根本就没有使用redis好不好。
一发查找,原来是spring-boot-starter-data-redis的鬼,在springboot中,pom中添加spring-boot-starter-data-redis依赖,在启动时会自动创建redis pool 。调用相关配置,而我们什么也没有配所以报错。
3.注释依赖
启动OK。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
版权声明:本文为l_z_w99原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。