Manoj Majumdar
Manoj Majumdar

Reputation: 525

Load @configuration based on property in spring boot

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?

Upvotes: 0

Views: 1592

Answers (1)

João Dias
João Dias

Reputation: 17500

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:

Upvotes: 1

Related Questions