Exception in thread "main" java.lang.IllegalStateException: beanfactory not initialized or already closed-call ' REFR Esh ' before accessing beans via the ApplicationContext
When encountering this kind of error, many people on the Internet are advised to solve this problem:
Beanfactory is not instantiated or has been closed, in fact, the cause of the error is very simple, in writing:
ApplicationContext CTX = new Classpathxmlapplicationcontext ();
, when the configuration file is not specified, spring instantiates beanfactory by default to Classpath to find the file named Applicationcontext.xml, but you do not specify it, so this error occurs.
This is the reason for the error, the name of the file in parentheses to write the line.
ApplicationContext CTX = new Classpathxmlapplicationcontext ("Applicationcontext.xml");
In that case, there would be no such mistake.
But there are other reasons for the error:
This error is also reported when your control layer controller file has duplicate names.
Beanfactory not initialized or already closed-call ' refresh ' before access