Spring 方法替换 了解一下

    其实说简单的就是一个A   Bean 在执行本方法的时候并不执行,而是调用另一个B    Bean方法

    要求B  implements MethodReplacer 

    

@Override
public Object reimplement(Object arg0, Method arg1, Object[] arg2)
throws Throwable {

return XXX;
}

   

<bean id="a" class="party.infoo.entity.A">
<property name="id" value="1"></property>
<property name="name" value="张三"></property>
<property name="age" value="11"></property>
<replaced-method name="getDog" replacer="b"></replaced-method>
</bean>

<bean id="b" class="party.infoo.entity.B"></bean>

上述就是说在调用A的getDog()方法时,实际上调用了B的reimplement方法

原文地址:https://www.cnblogs.com/infoo/p/6412201.html