Autowiring in servlet

后端 未结 2 2017
青春惊慌失措
青春惊慌失措 2020-12-02 20:17

i want to use spring autowiring in servlet so here\'s my code:

@Configurable
public class ImageServlet extends HttpServlet {

   @Autowired
   private Syst         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 21:01

    Remove the @Configurable annotation from your servlet and add:

    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext (this);
    

    at the first line of your init() method.

提交回复
热议问题