使用springboot方式配置监听器
//2.配置监听器 @Bean public ServletListenerRegistrationBean<DataInitializeListener> getDataInitializeListenerBean(){ ServletListenerRegistrationBean<DataInitializeListener> listenerRegistrationBean=new ServletListenerRegistrationBean<>(); listenerRegistrationBean.setListener(new DataInitializeListener()); return listenerRegistrationBean; }