父类是这样的
public interface father(){ }
在子类上添加@component("name")
第一个子类为
@Service
@component("boy")
public class boy implents father(){
}
第二个子类为
@Service
@component("girl")
public class girlimplents father(){
}
在需要调用时添加
@Resource("XX")
public class test{
@Resource("boy")
private father f;
}
这样在调用时就能准确的调用自己想要的子类了
微信公众号:二虎程序