我有一个关于spring上下文的问题。我的应用程序使用弹簧和弹簧调度器。 在web.xml中,我宣布:Spring上下文加载器
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
我的问题是:
如果我宣布org.springframework.web.context.ContextLoaderListener
在web.xml中,调度程序将运行两次,所有的豆类都是重复的,和应用程序启动时间大约160秒。
如果我删除org.springframework.web.context.ContextLoaderListener
, 春天抛出异常:No WebApplicationContext found: no ContextLoaderListener registered
。并且App启动时间缩短到80秒。
我该如何解决它?谢谢大家!
拆分您的配置。不要让'ContextLoaderListener'和'DispatcherServlet'加载相同的配置文件。如果你这样做,一切都会被加载两次。 – 2015-03-31 08:41:42
你甚至为什么要考虑使用XML配置?它是2015年 - http://www.kubrynski.com/2014/01/understanding-spring-web-initialization.html – 2015-03-31 10:14:00