目录结构:
src/main/resoures目录下有三个spring配置文件
applicationContext-actions.xml 这里面有:<import resource="applicationContext-beans.xml"/>
applicationContext-beans.xml 这里面有: <import resource="applicationContext-dao.xml"/>
applicationContext-dao.xml  这里面有:<import resource="classpath:entityContext.xml"/>src/main/webapp/WBE-INF里有
applicationContext.xml
web.xmlapplicationContext.xml里有一句:<import resource="classpath:applicationContext-actions.xml"/>在MyEclipse中用tomcat发布时报错:2009-12-28 16:19:12 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2009-12-28 16:19:12 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization started
2009-12-28 16:19:12 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1e78c96: display name [Root WebApplicationContext]; startup date [Mon Dec 28 16:19:12 CST 2009]; root of context hierarchy
2009-12-28 16:19:12 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2009-12-28 16:19:13 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext-actions.xml]
2009-12-28 16:19:13 org.springframework.web.context.ContextLoader initWebApplicationContext
严重: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext-actions.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-actions.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-actions.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:182)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:132)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at 

解决方案 »

  1.   

    我使用这种方式加载spring配置文件
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext-*.xml</param-value>
    </context-param>把所有的配置文件放在src下。
      

  2.   

     from class path resource [applicationContext-actions.xml]
    2009-12-28 16:19:13 org.springframework.web.context.ContextLoader initWebApplicationContext
    严重: Context initialization failed
    applicationContext-actions.xml 文件中的东西是
      

  3.   

    src/main/resoures添加到CLASS_PATH了喵?
      

  4.   

    <context-param>   
      <param-name>contextConfigLocation</param-name>   
      <param-value>/WEB-INF/applicationContext*.xml</param-value>   
      </context-param>
      

  5.   

      读取资源文件错误 
    <context-param>  
      <param-name>contextConfigLocation </param-name>  
      <param-value>/WEB-INF/applicationContext*.xml </param-value>  
      </context-param>
      

  6.   

    exception is java.io.FileNotFoundException: class path resource [applicationContext-actions.xml]明显是没有找applicationContext-actions.xml这个文件嘛
      

  7.   

    而且为什么不直接在
    applicationContext.xml中全部import呢,搞的一个import另一个的层层级联,看着不累吗?
      

  8.   

      applicationContext-beans.xml ,applicationContext-dao.xml 没有引入啊,当然会报错啊
        可以一个个引入或者使用5L的方法,试试。
      

  9.   

    大家说的很有道理哦。
      就是通过spring容器没有读到你写的配置文件。
      <context-param>  
      <param-name>contextConfigLocation </param-name>  
      <param-value>/WEB-INF/applicationContext*.xml </param-value>  
      </context-param>将spring 配置文件放到/WEB-INF目录下
      

  10.   

    <import resource="classpath:applicationContext-actions.xml"/> 
    classpath下有applicationContext-actions.xml吗