Skip to content
Advertisement

@Conditionalonproperty for complex objects to yaml

I am having yaml config with the next structure:

JavaScript

And I need to init bean only if “myComplexObject” property is present in config.

I’ve tried:

JavaScript

But in this case spring boot ignores property and do not init my bean.

But it works fine for simple structures like:

JavaScript

Is that possible to use @ConditionalOnProperty for complex objects ? Maybe there is some alternative to do the same?

Advertisement

Answer

Sure, try this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement