您的位置:首页 > 运维架构 > Tomcat

使用tomcat插件报错问题

2018-01-19 21:49 253 查看
今天,在搭建一个商城项目的过程中,遇到了这么一个问题java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

我是在service层启动的tomcat插件,由于习惯性的在web.xml文件中初始化spring容器,如下

<!-- 初始化spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

导致在tomcat启动的时候在classpath路径下找不到applicationContext_*.xml文件,(因为我还没有applicationContext_*.xml文件)导致报错。这算是一个很低级的错误,对于搭建环境来说,还是每一步用到的时候再增加,一步一步去搭建。对于高手来说,可以略过^^
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息