I'm using @ConstructorBinding
with @ConfigurationProperties
like this
@ConstructorBinding
@ConditionalOnProperty(name = "nexus.orchestration.cloud.model", havingValue = "true", matchIfMissing = false)
@ConfigurationProperties(value = "nexus.orchestration.model.cloud-bucket", ignoreUnknownFields = false)
@ToString
public static class ModelCloudBucket {
private final CloudBucket cloudBucket;
public ModelCloudBucket(final CloudProviderEnum provider, final String bucket, final String folder) {
this.cloudBucket = new CloudBucket(provider, bucket, folder);
}
}
I have @EnableConfigurationProperties(FlowCache.ModelCloudBucket.class)
on my main application class
However, the @ConditionalOnProperty
is not working. If my property is false and I comment out the CloudBucket object in the yaml file, it fails on startup because it can't bind the cloud bucket property. If the property is false, than that object should not be required and then bean should just be null. How can I make this work?