[英]Custom bean resolver for constructor parameter
Is it possible to provide a custom bean resolver to spring? 是否可以提供自定义的bean解析器来启动? I have a constructor 我有一个构造函数
Person(@myCustomAnnotation name : String)
I want to be able to put a different value for name based on if the annotation is there or not. 我希望能够根据注释是否存在为名称输入不同的值。
I think the @Value
annotation is what you're looking for. 我认为@Value
注释是您要寻找的。 Person will have to be a managed bean though. 人将必须是一个托管bean。
@Bean("jim")
fun getJim(@Value("\${person.name:Jim Jones}") name : String) = Person(name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.