V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
esolve
V2EX  ›  问与答

RedisTemplate Hash 操作抛出异常的问题

  •  
  •   esolve · Dec 7, 2017 · 3779 views
    This topic created in 3071 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   ·   1397 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 16:31 · PVG 00:31 · LAX 09:31 · JFK 12:31
    ♥ Do have faith in what you're doing.