Spring - Injecting a dependency into a ServletContextListener

前端 未结 4 1029
心在旅途
心在旅途 2020-11-27 16:59

I would like to inject a dependency into a ServletContextListener. However, my approach is not working. I can see that Spring is calling my setter method, but l

4条回答
  •  感动是毒
    2020-11-27 17:47

    As mentioned before the ServletContextListener is created by the server and so it is not managed by spring.

    If you wish to be notified of the ServletContext, you can implement the interface:

    org.springframework.web.context.ServletContextAware
    

提交回复
热议问题