Код: Выделить всё
@Getter
// Intentionally Validated and not jakarata.validation.Valid because Valid does not trigger
// validation for configuration properties, and I don't know why.
@Validated
@ConfigurationProperties(prefix = "pfx")
public class TenantsConfiguration {
@NotNull private final Map tenants;
@ConstructorBinding
public TenantsConfiguration(Map tenants) {
this.tenants = tenants;
}
@Getter
public static class TenantConfiguration {
@NotNull private final Optional field1;
@NotNull private final Optional field2;
@ConstructorBinding
public TenantConfiguration(
Optional field1, Optional field2) {
this.field1 = field1;
this.field2 = field2;
}
}
}
Код: Выделить всё
pfx:
tenants:
t1:
field1: abc
Код: Выделить всё
Binding to target TenantsConfiguration failed:
Property: pfx.tenants.t1.field2
Value: "null"
Reason: field2 must not be null
Подробнее здесь: https://stackoverflow.com/questions/792 ... properties
Мобильная версия