java.lang.IllegalStateException: BeanFactory not initialized or already closed
来源:互联网 发布:货源软件是什么 编辑:程序博客网 时间:2024/06/05 14:30
程序出现如下异常:
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1087)
at com.dalizatan.job.dao.test.TestJobMapper.testGetUserById(TestJobMapper.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
原因是:ApplicationContext对象声明错误
错误方式:ApplicationContext applicationContext = new ClassPathXmlApplicationContext();
正确方式:ApplicationContext applicationContext = new ClassPathXmlApplicationContext(bean.xml);
bean.xml表示spring中bean所在的文件
- 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
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' bef
- Spring报错java.lang.IllegalStateException: BeanFactory not initialized or already closed -call 'refres
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- ssh java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh'
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo
- 配置文件加载异常java.lang.IllegalStateException: BeanFactory not initialized or already closed
- spring整合jax-ws时报错(java.lang.IllegalStateException: BeanFactory not initialized or already closed)
- Spring报错java.lang.IllegalStateException: BeanFactory not initialized or already closed -call 'refres
- Spring报错java.lang.IllegalStateException: BeanFactory not initialized or already closed -call 'refres
- Spring报错java.lang.IllegalStateException: BeanFactory not initialized or already closed -call 'refres
- 1、玩转树莓派音频——DIY具有输入输出的声卡(非USB)
- socket error即Windows套接字错误代码
- poj1111 Image Perimeters
- [com.alibaba.druid.pool.DruidDataSource]abandon connection, open stackTrace 转载 2016年09月05日 15:25:06
- OpenCV学习笔记(一) 轮廓检测
- java.lang.IllegalStateException: BeanFactory not initialized or already closed
- oracle12C RAC GI + UDEV + ASM 在centos6下安装详细步骤
- Hibernate项目简单配置
- LeetCode#547 Friend Circles题解(C++版)
- Nginx 官方文档翻译
- 新浪微博正在审核的开发者平台应用添加测试账号
- python之enumerate()说明
- 51nod1264(计算几何入门题)
- 周总结