How to access a method a Spring Bean from a class not in the Spring Container

后端 未结 3 1166
遇见更好的自我
遇见更好的自我 2021-02-15 15:00

I\'m not a Spring pro, so please bear with me....

I have three classes:

class SpringBeanA {
    public aMethod() {
        .....
    }
}

class SpringBea         


        
3条回答
  •  抹茶落季
    2021-02-15 15:36

    Either you make Spring manage your NONSpringClass and enable injection of SpringBeanB in NONSpringClass class or you have to manually inject a proper instance of SpringBeanB in your NONSpringClass reference. In the latter approach, Spring has nothing to do, and you manually have to create the necessary instances and inject them using setters.

提交回复
热议问题