lundi 10 septembre 2018

How can I inject complex properties values using Spring @Value?

I have a field lets say "my_field", I want to inject that using @Value from Spring.

This is original initialization of that field.

val configPath: String = System.getenv("SOME_FILE").let {
    if (it.isNullOrBlank()) {
        System.getenv("GOPATH").let { gopath ->
            if (gopath.isNullOrBlank()) {
                "$workingDirectory/../config.json"
            } else {
                "$gopath/some_path/config.json"
            }
        }
    } else {
        it
    }
}

How can I rewrite it using @Value ?

Thank you for any help.

Aucun commentaire:

Enregistrer un commentaire