Spring get current ApplicationContext

后端 未结 11 923
陌清茗
陌清茗 2020-11-28 20:04

I am using Spring MVC for my web application. My beans are written in \"spring-servlet.xml\" file

Now I have a class MyClass and i want to

11条回答
  •  不思量自难忘°
    2020-11-28 20:49

    Step 1 :Inject following code in class

    @Autowired
    private ApplicationContext _applicationContext;
    

    Step 2 : Write Getter & Setter

    Step 3: define autowire="byType" in xml file in which bean is defined

提交回复
热议问题