zuomengdebanli

1.项目所有操作异常缓慢。

问题:

Spring的Application对象在每次获取 bean的时候均加载了一次application对象。

解决办法,对象只加载一次。

使用这段代码

ServletContext sc = ServletActionContext.getServletContext();
WebApplicationContext ac = WebApplicationContextUtils
.getRequiredWebApplicationContext(sc);
DwyzService dwyzService = (DwyzService) ac.getBean("DwyzService");

 

替代

AbstractApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"beans.xml"});
IHs002002Service hs002002Service=(IHs002002Service) ctx.getBean("Hs002002Service");

后问题解决。

分类:

技术点:

相关文章: