在web.xml中加入:
<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>
org.springframework.web.util.IntrospectorCleanupListener
</listener-class>
</listener>
//可以手动关闭Spring容器
//第一种方法
ClassPathXmlApplicationContext app = new ClassPathXmlApplicationContext("ApplicationContext.xml");
app.start();
app.close();
//第二种方法
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
AbstractApplicationContext sctx = (AbstractApplicationContext)ctx;
sctx.registerShutdownHook();