使用代理可以轻松实现。创建接口的委派实现,并切换要委派的对象。
@Component("BeanA")public class MyClass implements MyInterface { private MyInterface target; public void setTarget(MyInterface target) { this.target = target; } // now delegating implementation of MyInterface methods public void method1(..) { this.target.method1(..); } ..}


