BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Appli

在做Spring整合Struts2的时候,启动项目,就报了如下的错误

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

java.io.FileNotFoundException: Could not open ServletContext resource [/applicationContext.xml]


背景:

我是在xml文件中配置ioc容器,在jsp页面采用<%%>的形式调用实例


第一个错误:

BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

原因:

是配置文件的名称是contextConfigLocation,一点都不能错!!!!!


第二个错误:

java.io.FileNotFoundException: Could not open ServletContext resource [/applicationContext.xml]

原因:

是地址不对 

应该是classpath:applicationContext.xml


正确的配置文件应该如下:

 
  contextConfigLocation
  classpath:applicationContext.xml
 

 

 

你可能感兴趣的:(java之ssh框架专栏)