esolve
V2EX  ›  问与答

RedisTemplate Hash 操作抛出异常的问题

  •  
  •   esolve · Dec 7, 2017 · 3902 views
    This topic created in 3148 days ago, the information mentioned may be changed or developed.

    @Service class SomeService{ private HashOperations<String, String, Integer> intHashOps;

      @Autowired
      private  RedisTemplate<String, String> redisTemplate;
    
      @PostConstruct
      void init(){
    	hashOps = redisTemplate.opsForHash();
      }
    
      void do(){
        intHashOps.put("loginFailCount", username, 1);   //抛出异常
      }
    }
    

    上面的代码中,调用 do()抛出异常 java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String 这是怎么回事啊?

    esolve
        1
    esolve  
    OP
       Dec 7, 2017
    顶顶顶
    esolve
        2
    esolve  
    OP
       Dec 7, 2017
    顶顶顶顶
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4531 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:10 · PVG 18:10 · LAX 03:10 · JFK 06:10
    ♥ Do have faith in what you're doing.