My SessionListener component looks like this:
@Component
public class SessionListener implements HttpSessionListener{
@Autowired
private PeerConnectionRepository peerConnectionRepository;
...
}
Cause I use @Autowired i have to load SessionListener as component. I try to do it like this:
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Autowired
SessionListener sessionListener;
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(sessionListener);
}
...
}
But I get Failed to start component error. How to add this SessionListener as component to servletContext? Please for help, cheers.