通过FactoryBean实现,您可以在代码中的其他位置注册初始化回调:
@Bean fun documentSettings(): CustomizingFactoryBean<DocumentSettings> =
CustomizingFactoryBean.create()
@Bean fun documentSettingsCustomizerA(): Customizer<DocumentSettings> = Customizer {
settings -> settings.someVal = 1
}
@Bean fun documentSettingsCustomizerB(): Customizer<DocumentSettings> = Customizer {
settings -> settings.otherVal = 2
}
这将创建同时运行两个DocumentSettings
的{{1}}实例。
我想要实现的是跳过注册Customizer
并依靠组件扫描:
CustomizingFactoryBean<DocumentSettings>
是否为此创建自定义BeanFactoryPostProcessor?
我是否可以插入现有的一种处理方式@CustomizableComponent
class DocumentSettings( var someVal: Int, var otherVal: Int)
,@Service
,@Component
?