参数是什么意思?"/>
Spring 中 @Bean修饰的方法中的参数是什么意思?
先看一个例子
...
public class ProcessEngineAutoConfiguration extends AbstractSpringEngineAutoConfiguration {...@Bean@ConditionalOnMissingBeanpublic RepositoryService repositoryServiceBean(ProcessEngine processEngine) {return processEngine.getRepositoryService();}...
}
其中@Bean所修饰的方法是带参数的,这个参数是什么意思呢?
其实就是代表@Bean所标注的对象(RepositoryService)的实例化依赖于
参数中的类,需要先将参数中的类实例化,才能实例化@Bean所标注的对象。
写了一个例子,很简单,您可以试一下,不再赘述!
demo_autoconfiguration
参考资料
- @Bean with parameters
- 隐式注入
更多推荐
Spring 中 @Bean修饰的方法中的参数是什么意思?
发布评论