Manoj
03/02/2022, 10:25 AM@ Value annotation in spring with Kotlin?Sam
03/02/2022, 10:26 AM$ has special meaning in Kotlin strings, you need to escape it with \Sam
03/02/2022, 10:27 AM@Value("\${my.config.property}")Manoj
03/02/2022, 10:28 AMSam
03/02/2022, 10:31 AMlateinit properties. Can you share an example of the code?Manoj
03/02/2022, 10:33 AM@Component
class MongoClient {
@Value("\${mongodb.host}")
private lateinit var host: String
}Sam
03/02/2022, 10:36 AMManoj
03/02/2022, 10:36 AMSam
03/02/2022, 10:37 AM@Component
class MongoClient(@Value("\${mongodb.host}") private val host: String) {
...
}Manoj
03/02/2022, 10:38 AMSam
03/02/2022, 10:39 AMSam
03/02/2022, 10:39 AMlateinit varSam
03/02/2022, 10:39 AMMongoClient()?Manoj
03/02/2022, 10:39 AMSam
03/02/2022, 10:40 AMManoj
03/02/2022, 10:41 AMSam
03/02/2022, 10:44 AMMongoClient, you should get hold of it by injection. This isn't really specific to Kotlin, it's a general Spring topic. I would suggest following a tutorial on Spring dependency injection.Manoj
03/02/2022, 10:46 AM