What you mean is listeners for the Spring life cycle. This is not what you want.
Spring boot documentation state :
When using the built-in servlet container, you can register servlets, Filters, and all listeners from the Servlet specification (e.g. HttpSessionListener) directly as Spring beans. This can be especially convenient if you want to reference the value from your application.properties during configuration.
UPDATE:
import org.springframework.context.annotation.Bean; import javax.servlet.http.HttpSessionListener; @Bean public HttpSessionListener httpSessionListener(){
source share