Home > database >  Load @configuration based on property in spring boot
Load @configuration based on property in spring boot

Time:12-10

I am learning spring batch, and trying to load job configuration based on some property. Is this possible, can we load @Configuration classes based on some property. If yes how to achieve that?

CodePudding user response:

Yes, you just need to use @ConditionalOnProperty in your @Configuration class as follows:

@Configuration
@ConditionalOnProperty(name = {"your-property-name"}, havingValue = "true")
public class ConditionalConfiguration {}

You can find more information in the following online resources:

  • Related