[英]@Bean annotation name attribute value to take from properties file
I want to read @Bean
annotations name
attribute value from properties file, something like below.我想从属性文件中读取
@Bean
annotations name
属性值,如下所示。
Properties File:属性文件:
myBeanName: abc
In java code I want to achieve as below,在 java 代码中我想实现如下,
@Bean(name = "${myBeanName}")
Which should be equal to @Bean(name = "abc")
@Bean(name = "${myBeanName}")
应该等于@Bean(name = "abc")
Thanks in advance.提前致谢。
You can achieve this with https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.html您可以使用https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ImportBeanDefinitionRegistrar.ZFC335FDC70D5FCC67A9D
But I think your actual problem has easier solution但我认为你的实际问题有更简单的解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.