esolve
V2EX  ›  问与答

RedisTemplate Hash 操作抛出异常的问题

  •  
  •   esolve · Dec 7, 2017 · 3826 views
    This topic created in 3103 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   ·   926 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 19:28 · PVG 03:28 · LAX 12:28 · JFK 15:28
    ♥ Do have faith in what you're doing.