redis报错:jedis connection exception unexpected end of stream

一般的话,原因是你在spring中把jedis客户端配置成了单例模式(singleton),所以当在极短时间内,有多个请求连续发送过来时,jedis就会报错,说一个连接还没结束。

所以正确的配置是,将jedis配置成原型模式,每一次注入都产生一个新对象。


     <bean name="redis" class="redis.clients.jedis.Jedis" scope="prototype" >
       <constructor-arg name="host">
          <value>127.0.0.1value>
       constructor-arg>
       <constructor-arg name="port">
          <value type="int">6379value>
       constructor-arg>
     bean>

上面的代码中,增加了scope="prototype"


参考:
Unexpected end of stream

看 “dbubenheim ”回到部分

你可能感兴趣的:(redis)