java - Spring get current ApplicationContext -
I'm using Spring MVC for my web application my beans " spring-servlet.xml "The file is written
Now I have a class
MyClass and I want to use this class using Spring Beans
I have written the following in
spring-servlet.xml
bean id = "miracles" category = "comm. MyClass" /> Now let me get this ApplicationContext
ApplicationContext context = ?? I need to use so that I can
MyClass myClass = (MyClass) context.getBean ("myClass"); How to do this ??
Just inject it. @Autowired Private ApplicationContext appContext;
Or apply this interface:
Comments
Post a Comment