在进行maven+spring+struts+hibernate整合时发生class path resource [spring.xml] cannot be opened because it do及BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext找不到bean错误时,在web.XML中加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring.xml,classpath*:applicationContext*.xml</param-value>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring.xml,classpath*:applicationContext*.xml</param-value>
</context-param>
在classpath后面加*,因为classpath默认路径不是src下的resource文件
本文介绍了解决Maven+Spring+Struts+Hibernate整合时出现的classPathResource[spring.xml]无法打开及BeanFactory未初始化等错误的方法。通过在web.xml中正确配置contextConfigLocation参数,确保Spring能够加载指定的配置文件。

659

被折叠的 条评论
为什么被折叠?



