简体   繁体   中英

Custom bean resolver for constructor parameter

Is it possible to provide a custom bean resolver to spring? 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. Person will have to be a managed bean though.

@Bean("jim")
fun getJim(@Value("\${person.name:Jim Jones}") name : String) = Person(name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM