java.lang.IllegalStateException: BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext
原因
BeanFactory 未初始化或已关闭
BeanFactory not initialized or already closed
在通过应用程序上下文访问 bean 之前调用“刷新”
call ‘refresh’ before accessing beans via the ApplicationContext
解决方法:
未指定applicationContext.xml配置文件
错误写法:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
正确写法:
ApplicationContext context = new ClassPathXmlApplicationContext("applicicationContext.xml");