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

Popular posts from this blog

sql - Return Function using Cursor -

c++ - why does this code produce a runtime error? -

javascript - Is there any way to add a new parameter to a function programmatically? -