Spring配置遇到的一些错误
错误:
>
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext
原因:spring初始化bean对象出错,id重复
IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml];
原因:如果不特意指定参数名为contextConfigLoction的元素,那么spring的ContextLoderListener监听器就会在/WEB-INF/下去寻找并加载该目录下的名为applicationContext.xml这个文件
解决:在web.xml中添加标签并再次指定spring核心文件的位置。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
structs2配置
错误:
java.lang.ClassNotFoundException: org.apache.structs2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
解决:2.1.3版本以前用org.apache.struts2.dispatcher.FilterDispatcher
2.1.3版本以后用org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
spring和struts2整合
Action class [categoryAction] not found - action - file:/D:/myeclipse2014_workspace/.metadata/.me_tcat7/webapps/ssh/WEB-INF/classes/struts.xml:11:68
解决:导包 struts2-spring-plugin-2.3.4.jarThere is no Action mapped for namespace [/] and action name [listCategory] associated with context path [/ssh]. - [unknown location]
解决:配置文件和jar包问题,找不到actionmyeclipse中复制的web项目在部署到tomcat中时会部署之前的项目
解决:右键点击复制的web项目→properties→Myeclipse→project Facets→web→web context-root中输入复制后的项目名重新部署就好了