redis和session共用同時使用 報錯

來源:互聯網
上載者:User

reids報錯

/**     * 注意如果 JedisConnectionFactory與JedisPool一起使用會報錯<br/>     *      * @return     */    @Bean    @Order(2)    // @ConfigurationProperties(prefix = "spring.redis")    public JedisConnectionFactory getConnectionFactory() {        JedisConnectionFactory factory = new JedisConnectionFactory();        factory.setUsePool(true);        if (config == null) {            // BaseApplication.getBeanFactory().createBean(JedisPoolConfig.class);            config = getRedisConfig();        }        factory.setPoolConfig(this.config);        logger.info("JedisConnectionFactory bean init success.");        return factory;    }//  @Bean//  @Order(3)//  public JedisPool getRedisPool() {//      if (config == null) {//          // BaseApplication.getBeanFactory().createBean(JedisPoolConfig.class);//          config = getRedisConfig();//      }//      JedisPool jedisPool = new JedisPool(config, host, port, 15000, password, 1);//      return jedisPool;//  }
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.2018-03-24 15:49:32.517 ERROR [main] [hio-sys] o.s.boot.SpringApplication - Application startup failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: 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    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:543)    at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)    at com.jzy.hio.HioSysApplication.main(HioSysApplication.java:36)Caused 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    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:204)    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:348)    at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterPropertiesSet(RedisHttpSessionConfiguration.java:249)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)    ... 16 common frames omittedCaused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool    at redis.clients.util.Pool.getResource(Pool.java:53)    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)    at redis.clients.jedis.JedisPool.getResource(JedisPool.java:16)    at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:194)    ... 20 common frames omittedCaused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect    at redis.clients.jedis.Connection.connect(Connection.java:207)    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)    at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1767)    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:106)    at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:888)    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:432)    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)    at redis.clients.util.Pool.getResource(Pool.java:49)    ... 23 common frames omittedCaused by: java.net.ConnectException: Connection refused: connect    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)    at java.net.Socket.connect(Socket.java:589)    at redis.clients.jedis.Connection.connect(Connection.java:184)    ... 30 common frames omitted
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.