esolve
V2EX  ›  问与答

RedisTemplate Hash 操作抛出异常的问题

  •  
  •   esolve · Dec 7, 2017 · 4103 views
    This topic created in 3261 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
    esolve
    OP
    Dec 7, 2017
    1
    顶顶顶
    esolve
    esolve
    OP
    Dec 7, 2017
    2
    顶顶顶顶
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4319 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 08:17 · PVG 16:17 · LAX 00:17 · JFK 03:17
    ♥ Do have faith in what you're doing.