问题描述
`Exception in thread “main” 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:168)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
at MyTest.main(MyTest.java:8)
原因分析:
获取spring上下文对象时未正确加载配置文件
解决方案:
仔细检查要加载的配置文件名称