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

RedisTemplate Hash 操作抛出异常的问题

  •  
  •   esolve · Dec 7, 2017 · 3761 views
    This topic created in 3063 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   ·   3817 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 00:44 · PVG 08:44 · LAX 17:44 · JFK 20:44
    ♥ Do have faith in what you're doing.