First: Get the file name under the root directory
ApplicationContext ac = new Classpathxmlapplicationcontext (".. /MVC-dispatcher-servlet.xml ");
The second Kind
ApplicationContext ac = new Filesystemxmlapplicationcontext ("Applicationcontext.xml");
Third Kind
ApplicationContext AC1 = webapplicationcontextutils.getrequiredwebapplicationcontext (ServletContext SC);
Fourth type
Extends Applicationobjectsupport;
Injected through the Set method,
Fifth type
Implements Applicationcontextaware
private static ApplicationContext Apptext;
Injected by the Set method
@Override
public void Setapplicationcontext (ApplicationContext arg0)
Throws Beansexception {
TODO auto-generated Method Stub
asteriskeventlistenerinit.apptext=arg0;
}
By reading the configuration file generated by the ApplicationContext, if, in the configuration file like the task Scheduler such configuration, will cause multiple tasks to trigger, please be careful.
Spring gets ApplicationContext