Adey
Adey

Reputation: 2226

kotlin spring inject map from application.properties

I need to inject the Map<String, String> from the application.properties file in key-value format using Spring annotation @Value in Kotlin.

Upvotes: 1

Views: 943

Answers (1)

Adey
Adey

Reputation: 2226

You can inject map from property file as below

example.map={key1:'value1',key2:'value2'}

Inject in Kotlin

@Value("#{\${example.map}}")
val myMap: Map<String, String> = mapOf()

Upvotes: 1

Related Questions