dodalovic
11/11/2020, 2:48 PMkotlin
@ConstructorBinding
@ConfigurationProperties("company")
class UsersProperties(val users: Map<String, User>) {
data class User(
val password: String,
val companyName: String,
val accounts: List<String>
)
}
and this in my application.yaml
yaml
company:
users:
<mailto:admin@email.com|admin@email.com>:
password: admin
companyName: Company 1
accounts: [ "ACC1", "ACC2" ]
<mailto:user@user.com|user@user.com>:
password: user
companyName: Company 2
accounts: [ "ACC3", "ACC4" ]
spring complains that users
property can't be null
Any idea?
Thanks in advancejbnizet
11/11/2020, 4:21 PMcompany.users.admin@email.com.password
for example, where the dot in the email address now becomes a property separator. You should probably use a list of users, with an additional email
property, and simply have a toMap()
method in the properties that returns the list of users as a map.dodalovic
11/11/2020, 5:05 PM