views:

14

answers:

0

I have a web application set up like this:

  1. Embedded Jetty instance is started from Main with DispatcherServlet with name "myservlet" inside it.

  2. File myservlet-servlet.xml exists in resourceBase of that servlet. It contains only these lines:

    <context:component-scan base-package="com.mycompany.myapp.config.spring" /> <context:component-scan base-package="com.mycompany.myapp.controller" />

  3. In the package com.mycompany.myapp.config.spring there are server @Configuration classes; in com.mycompany.myapp.controller there are several @Controller classes.

The problem is that even if I make my beans defined in @Configuration implement Lifecycle interface, method start() is never called, which forces me to put start/stop logic into @PostConstruct and @PreDestroy methods, which I'd like to avoid.

Is there a way to make Lifecycle work in my application?