Spring 中 @Bean修饰的方法中的参数是什么意思?

编程入门 行业动态 更新时间:2024-10-09 19:23:02

Spring 中 @Bean修饰的方法中的<a href=https://www.elefans.com/category/jswz/34/1771441.html style=参数是什么意思?"/>

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修饰的方法中的参数是什么意思?

本文发布于:2024-02-05 11:32:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1745302.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   方法   Spring   Bean

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!