异常BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Appl

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ceoicac/article/details/79970653

异常:BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext

网上查了很多解决的方法,这里我说我的失误导致的这个异常.
我是刚从SVN获取的项目,获取下来后配好数据,然后启动项目,然后就是出现了这个异常,以前也遇到一次,但是忘记了怎么解决了,后来去看文档,发现自己漏了一个步骤,没有配置java build path,泪奔了。

问题原因:

没有为项目配置:java build path

解决步骤:

点击项目>>右键>>Properties>>然后java Build Path>>配置你的jDK吧>>然后重启项目,完成。

求助错误,BeanFactory not initialized or already closed

10-17

[b]rnjunit4测试报错[/b]rnrnjava.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContextrn at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:153)rn at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)rn at com.test.testUserService.testAdd(testUserService.java:16)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at junit.framework.TestCase.runTest(TestCase.java:164)rn at junit.framework.TestCase.runBare(TestCase.java:130)rn at junit.framework.TestResult$1.protect(TestResult.java:110)rn at junit.framework.TestResult.runProtected(TestResult.java:128)rn at junit.framework.TestResult.run(TestResult.java:113)rn at junit.framework.TestCase.run(TestCase.java:120)rn at junit.framework.TestSuite.runTest(TestSuite.java:228)rn at junit.framework.TestSuite.run(TestSuite.java:223)rn at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnrnrnpackage com.test;rnrnimport junit.framework.TestCase;rnrnimport org.springframework.context.ApplicationContext;rnimport org.springframework.context.support.ClassPathXmlApplicationContext;rnrnimport com.model.User;rnimport com.service.UserService;(省略了包的导入)rnrnpublic class testUserService extends TestCase rnrn public void testAdd()rn ApplicationContext ctx = new ClassPathXmlApplicationContext();rn rn UserService service = (UserService)ctx.getBean("bean.xml");rn rn User user = new User();rn rn user.setName("a");rn user.setPassword("b");rn service.add(user);rn rnrnrnrnrnrn rn rn rnrn rn rn rnrn rnrn rnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭