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

后端 未结 3 1181
遇见更好的自我
遇见更好的自我 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:29

    A simple way to do this is using ApplicationContext.getBean().

    It's worth pointing out that this is considered bad practice, since it breaks inversion of control.

提交回复
热议问题