原因是spring配置文件,开启了事务导致的,redis是缓存用的,不需要开启事务,正确的配置如下:

<!--redis操作模版,使用该对象可以操作redis  -->  
    <bean  >    
        <property name="connectionFactory" ref="connectionFactoryTax" />    
        <!--如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String!!  -->    
        <property name="keySerializer" >    
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />    
        </property>    
        <property name="valueSerializer" >    
            <bean class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" />    
        </property>    
        <property name="hashKeySerializer">    
            <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>    
        </property>    
        <property name="hashValueSerializer">    
            <bean class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>    
        </property>    
        <!--开启事务  -->  
        <property name="enableTransactionSupport" value="false"></property>  
    </bean >   

  

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-01-18
  • 2021-10-07
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2022-02-26
  • 2021-08-21
  • 2022-01-15
  • 2021-10-28
  • 2022-12-23
  • 2022-01-08
相关资源
相似解决方案