首页 > 编程语言 > 详细

SpringMvc学习

时间:2018-05-30 15:59:45      阅读:193      评论:0      收藏:0      [点我收藏+]

遇见的问题:

1.Resource leak: ‘context‘ is never closed

spring实例化时

public void test2() {
  ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
  //配置文件中的id属性
  HelloService service = (HelloService) ctx.getBean("helloService");
  service.sayHello();
}

可以将前面用子类来写,并关闭

public void test2() {
  ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
  //配置文件中的id属性
  HelloService service = (HelloService) ctx.getBean("helloService");
  service.sayHello();
  ctx.close();
}

SpringMvc学习

原文:https://www.cnblogs.com/zkaiw/p/9111324.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!