【发布时间】:2017-04-24 14:35:15
【问题描述】:
我尝试使用@Bean(value="") 属性创建一个Bean 及其名称。 value 应设置为Spring EL Expression。
@Configuration
public class TestClass{
@Autowired
TestProperty testProperty
@Bean(value="#{testProperty.name}")
public MyBean myBean(){
MyBean b = new MyBean();
return b;
}
}
我的testProperty 是正确注入的,并拥有一个值,例如testProperty.name = "Bean1"
目前我创建的 Bean 只是将 EL 表达式作为其名称:{"bean":"#{testProperty.name}"
如何将 MyBean 的名称从 testProperty.name 命名?
【问题讨论】:
-
我真的怀疑你是否可以使用 SpEL 或 bean 名称。你能详细说明你的用例吗?
-
@luboskrnac 我的用例是我必须在属性文件中创建外部配置的石英作业。所以它可以是一份或多份工作。我有关于这个问题的another open question。也许这可以给你上下文。
-
我已经回答了你的一个非常相似的问题:stackoverflow.com/questions/40929161/…
标签: java spring spring-boot spring-el