我有一组类,如下所示。只注册Spring应用程序上下文接口的实现?
public class ServiceA implements CommonInterface
{
public void startA()
{
....
}
}
public class ServiceB implements CommonInterface
{
public void startB()
{
....
}
}
是否有弹簧框架自动注册只有其实现CommonInterface到应用程序上下文和访问他们班什么办法?
为什么不使用'@ Service'注释的任意实现?为什么不使用具有实现类型的'@ Autowire'来访问? –
@KenBekov:'@ Service'将通过扫描base-packages来启用注册。但是我需要更多的过滤器,例如 - 实现CommonInterface的类类型。另一方面,@ Autowire'只会帮助自动注入引用对象,这不是我的场景。 –