问题BeanFactory not initialized or already closed
来源:互联网 发布:英国的域名 编辑:程序博客网 时间:2024/06/07 08:04
问题BeanFactory not initialized or already closed - call 'refresh' before access
在网上查找很久,很多人说是因为
错误写法:ApplicationContext ctx = new ClassPathXmlApplicationContext();
时,没有指定配置文件,Spring实例化BeanFactory的时候是默认到classPath下面查找名为applicationContext.xml的文件的,但是呢,你又没有指定,所以出现了这个错误。
这就是错误的原因,在括号写上配置文件名就行了。
正确写法:ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
但是,我并没有写这个东西,我使用的是springmvc框架:后来发现问题在于在不同的包结构下存在相同名字的controller。导致Spring实例化BeanFactory失败。如果@Controller里面的value你没有设置的话,spring会按照你的class名称去实例化属于它的bean,当出现两个相同的class名称的时候就会报错。所以我们写程序的时候一定要避免相同名称的controller。当然如果你一定要若干个相同名称的controller。那么在注解@Controller加上不同的value属性。如:@Controller(value="controller01") 、@Controller(value="controller02")……
阅读全文
0 0
- 问题BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- BeanFactory not initialized or already closed - call 'refresh' before access
- idea报错:BeanFactory not initialized or already closed
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- tomacat 启动时报错 : BeanFactory not initialized or already closed
- 问题BeanFactory not initialized or already closed - call 'refresh' before access
- BeanFactory not initialized or already closed - call 'refresh' before accessing beans解决办法
- OOA:面向对象
- 字符统计
- BeanFactory not initialized or already closed
- Spring 框架及相关问题记录
- 《Spring实战》学习笔记之一:Spring之旅
- 问题BeanFactory not initialized or already closed
- * 继承与派生 编程题#1(Coursera 程序设计与算法 专项课程3 C++程序设计 郭炜、刘家瑛;OpenJudge)
- LeetCode刷题(13)
- 关于javaweb中sql语句中使用变量的情况
- 10个不得不买的高科技智能机器人
- 设计模式-动态代理
- 后缀表达式、前缀表达式
- 单节点安装openstack 之 计算节点nova 安装
- IRC---极客范儿
u010918487
2017-09-16 09:202楼qq_38127945
2017-06-01 09:491楼