public class WebContextListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContextEvent.getServletContext());
ISrInforService srInforService = applicationContext.getBean(ISrInforService.class);
// ISrInforService srInforService = (ISrInforService) applicationContext.getBean("srInforService");
srInforService.countAllSrInforsScore();
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
}
ISrInforService srInforService = applicationContext.getBean(ISrInforService.class);
或
ISrInforService srInforService = (ISrInforService) applicationContext.getBean("srInforService");
都可以。
然后配置web.xml
:
<!-- Spring监听配置,Web容器启动自动装配ApplicationContext的配置信息-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
参考:
最新评论
怎么获取下载密码不对啊?
你给钱了吗在这叫
夸克和百度给了你钱吧?这么多不限速的网盘不用,限速限的一坨屎一样的网盘拼命推荐
博主能不能回复一下具体什么时候更新新版,我怕到时候强制更新就用不了