I have a web application set up like this:
Embedded Jetty instance is started from Main with
DispatcherServletwith name "myservlet" inside it.File
myservlet-servlet.xmlexists 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.springthere are server@Configurationclasses; incom.mycompany.myapp.controllerthere are several@Controllerclasses.
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?