I have a web application set up like this:
Embedded Jetty instance is started from Main with
DispatcherServlet
with name "myservlet" inside it.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" />
In the package
com.mycompany.myapp.config.spring
there are server@Configuration
classes; incom.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?