Spring DI - Autowired property is null in a REST service

前端 未结 4 1217
攒了一身酷
攒了一身酷 2020-11-27 17:49

I\'m getting started with Spring DI, but I\'m struggling with dependency injection and the worse part is that I\'m not even sure why as it seems ok to me. Hopefully you guys

4条回答
  •  情歌与酒
    2020-11-27 18:41

    Another possible option is to manually invoke autowiring in your jersey resource:

    @Context
    private ServletContext servletContext;
    
    @PostConstruct
    public void init() {
        SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, servletContext);
    }
    

    Hmm, you get a "manual autowiring"...

提交回复
热议问题