springboot redis 订阅报错

在对接一个投资项目时,启动项目出现如下错误,本来想直接问对接人,但他们没有出现这种情况,只能看一下。

由下面异常可以看出,Redis security建议禁用CONFIG命令,以便远程用户无法重新配置实例。

RedisHttpSessionConfiguration需要在初始化期间访问它。托管的Redis服务,在默认情况下禁用此命令,并且没有重新启用该命令的选项。

而且spring-session-redis需要使用键空间通知(keyspace notification)这个功能。

 

解决方式: 1. 配置notify-keyspace-events 2. 设置ConfigureRedisAction为NO_OP不加载CONFIG

其中在https://github.com/spring-projects/spring-session/issues/124,作者给出了比较详细的答案

下面看我的解决方式。

1. 开启notify-keyspace-events

2. 自定义配置加载ConfigureRedisAction为NO_OP

@Bean
public static ConfigureRedisAction configureRedisAction() {
   return ConfigureRedisAction.NO_OP;
}

 

下面是错误

2018-12-09 00:28:19.245  WARN 16648 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is com.lambdaworks.redis.RedisCommandExecutionException: ERR unknown command 'CONFIG'
2018-12-09 00:28:21.487  INFO 16648 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-12-09 00:28:21.496  INFO 16648 --- [ost-startStop-2] o.s.c.n.zuul.ZuulFilterInitializer       : Stopping filter initializer context listener
2018-12-09 00:28:21.516  WARN 16648 --- [ost-startStop-2] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2018-12-09 00:28:21.531  INFO 16648 --- [           main] utoConfigurationReportLoggingInitializer : 

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is com.lambdaworks.redis.RedisCommandExecutionException: ERR unknown command 'CONFIG'
    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值