Issue
I need to inject some config values into a bean, and I am trying to use the new dsl for kotlin. Basically, I need the java equivalent of the following, but for kotlin bean DSL
public Thing myThing(@Value("${foo}") String foo) {
return new Thing(foo)
}
in Kotlin DSL:
val beans = beans {
bean {
Thing("????? How to get foo") // I need @Value("${foo}") here
}
}
Solution
You can use env
import org.springframework.core.env.get
val beans = beans {
bean {
Thing(env["foo"])
}
}
Answered By - sidgate
Answer Checked By - Marie Seifert (JavaFixing Admin)