[英]Autowire a default implementation if implemenation bean is not found
I have an interface with 2 default methods. 我有一个界面有2个默认方法。 If the implementation is not found, I wish autowire a proxy bean with these 2 default methods.
如果找不到实现,我希望使用这两种默认方法自动装配代理bean。 Is this possible in spring?
这可能在春天吗?
You need to define bean in some configuration 您需要在某些配置中定义bean
@Bean
@ConditionalOnMissingBean
public Foo foo(){
return new Foo() {};
}
where Foo
is your interface. Foo
是你的界面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.