V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
guyeuro
V2EX  ›  问与答

@Autowired @Resource 之类的注解和初始化块哪个先执行?

  •  
  •   guyeuro · 2017-08-23 14:35:16 +08:00 · 1369 次点击
    这是一个创建于 2454 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如下代码,出错了

    public class MyController{
      @Autowired
      private RedisTemplate<String, String> redisTemplate;
    
      SetOperations<String, String> setOperations;
      HashOperations<String, String, String> hashOperations;
    
      {
        setOperations = redisTemplate.opsForSet();
        hashOperations = redisTemplate.opsForHash();
      }
    

    是不是注解没有初始化块先执行? 这种状况如何改?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2776 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:44 · PVG 14:44 · LAX 23:44 · JFK 02:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.