我们在SpringBoot中用Jedis来访问Redis,其中Redis是采用集群(单机没有本篇文章的问题)的方式,在启用Redis的时候碰到如上问题。

错误的核心信息如下:

Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource

完整信息如下:

// 下午4::  .   ____          _            __ _ _
// 下午4:: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
// 下午4::( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
// 下午4:: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
// 下午4:: ' |____| .__|_| |_|_| |_\__, | / / / /
// 下午4:: =========|_|==============|___/=/_/_/_/
// 下午4:: :: Spring Boot :: (v1.5.1.RELEASE)
// 下午4::
// 下午4::40Nov , :: PM com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig readBoolean
// 下午4::40INFO: profiler.jdk.http.param=true
// 下午4::40Nov , :: PM com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig readBoolean
// 下午4::40INFO: profiler.jdk.http.param=true
// 下午4::40Nov , :: PM com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig readBoolean
// 下午4::40INFO: profiler.jdk.http.param=true
// 下午4::52org.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.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
// 下午4:: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.AbstractBeanFactory$.getObject(AbstractBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:)
// 下午4:: at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:)
// 下午4:: at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:)
// 下午4:: at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:)
// 下午4:: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
// 下午4:: at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:)
// 下午4:: at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:)
// 下午4:: at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:)
// 下午4:: at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
// 下午4:: at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
// 下午4:: at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
// 下午4:: at com.zte.Application.main(Application.java:)
// 下午4:: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
// 下午4:: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
// 下午4:: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
// 下午4:: at java.lang.reflect.Method.invoke(Method.java:)
// 下午4:: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:)
// 下午4:: at org.springframework.boot.loader.Launcher.launch(Launcher.java:)
// 下午4:: at org.springframework.boot.loader.Launcher.launch(Launcher.java:)
// 下午4:: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:)
// 下午4::52Caused by: org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
// 下午4:: at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:)
// 下午4:: at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:)
// 下午4:: at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotifica

经查找,在Java代码中,我们使用了注解:@EnableRedisHttpSession,这个注解是用来开启Redis来集式式管理Session。

而在使用这种方式的时候,是需要Redis开启Keyspace Notifications功能的,默认是关闭的。

这个功能有一个参数来控制它,notify-keyspace-events,值为Egx。

可以通过在Redis.Config中配置。

也可以通过命令行来配置,如下所示:

     redis-cli config set notify-keyspace-events Egx

然后重启Redis生效。

参考文档:

https://docs.spring.io/spring-session/docs/current/reference/html5/#api-redisoperationssessionrepository-sessiondestroyedevent

http://blog.csdn.net/xiaoyu411502/article/details/51248980

Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource的更多相关文章

  1. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...

  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r ...

  3. MyBatis笔记----报错:Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/ij34/mybatis/applicationContext.xml]: Invocation of init method failed; nested exception is org.sp

    四月 05, 2017 4:51:02 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...

  4. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stu' defined ...

  5. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

  6. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable t

    spring与hibernate整合然后出现如下错误: org.springframework.beans.factory.BeanCreationException: Error creating ...

  7. Spring AOP 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource..........

    完整报错如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'befo ...

  8. Error creating bean with name 'us' defined in class path resource [com/liuyang/test/DI/beans2.xml]: Cannot resolve reference to bean 'daoa' while setting bean property 'daoa'; nested exception is org.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'us' defined ...

  9. Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cannot resolve reference to bean 'factory' while setting bean property 'sqlSessionFactory'; nested excep

    Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cann ...

随机推荐

  1. 基于InfluxDB实现分页查询功能

    InfluxDB作为时序数据库中的翘楚,应用范围非常广泛,尤其在监控领域. 最近做了一个功能,将InfluxDB中的数据查询出来后,在前台分页展现,比如每页10条,一共100页,可以查看首页.末页,进 ...

  2. 《Inside C#》笔记(五) 方法

    方法用来体现类的行为. 一 相关概念 a) ref和out 通常一个方法只能返回一个值,但如果确实需要返回多个值时,可以使用ref或out.如果方法的参数被标注为ref或out,在调用该方法时,会传递 ...

  3. Java:【面向对象:类的定义,静态变量,成员变量,构造函数,封装与私有,this】

    本文内容: 什么是面对对象 类的定义与对象实例化 成员变量 成员变量的有效范围 成员变量的赋值 静态变量.方法与实例变量.方法 构造函数 封装与私有 this关键字 注:函数和方法是一样东西.[由于我 ...

  4. C#获取H5页面上传图片代码

    基于上一篇的H5压缩上传图片,由于图片是以二进制字符流blob的形式传过来的,所以应该想将其转成bytes类型再进行转换 public void ProcessRequest(HttpContext ...

  5. [Kali_Debian] 清除无用的库文件(清理系统,洁癖专用)-布布扣-bubuko.com - Google Chrome

    [Kali_Debian] 清除无用的库文件(清理系统,洁癖专用) 时间:2014-11-07 16:25:36      阅读:1486      评论:0      收藏:0      [点我收藏 ...

  6. EntityFramework Code-First 简易教程(四)-------继承策略

    在前篇CodeFirst类型约定中,我们在数据库中为每一个模型类创建一个表,但是有个问题,我们可以设计出带继承关系的模型类,即面向对象编程既有“has a”(表示类继承)也有“is a”(表示类包含) ...

  7. iptable用法

    一:添加屏蔽IP #禁止此IP访问服务器iptables -I INPUT -s 1.2.3.4 -j DROP或iptables -A INPUT -s 1.2.3.4 -j DROP#禁止服务器访 ...

  8. vmware linux 虚拟机开机状态加硬盘

    在开机状态先加一块盘,如图: 在系统中查看当前硬盘状态: 新加的硬盘还没刷出来.执行如下命令再试一下: $ echo "- - -" >/sys/class/scsi_hos ...

  9. Maven 变量及常见插件配置详解

    Maven 的 pom.xml 常用 变量 插件 配置 详解 一.变量 - 自定义变量及内置变量 1. 自定义变量 <properties> <project.build.name& ...

  10. Windows Server 2008 R2终端服务器激活方法

    本文描述了如何激活Windows Server 2008 R2的终端服务器的方法. 目录: 1.Windows Server  2008 R2终端服务器的安装 2.Windows Server  20 ...