@ConfigurationOnProperty

Spring Boot provides a feature called "Conditional Configuration" that allows you to conditionally enable or disable a configuration class based on the evaluation of certain conditions.

Here's a simple example of how you can achieve this:

Suppose you have a configuration property in your application.properties file:

myapp.feature.enabled=true

Now, you can create a configuration class and annotate it with @ConditionalOnProperty:

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(name = "myapp.feature.enabled", havingValue = "true")
public class MyFeatureConfig {

    // Your configuration beans or methods go here

}

In this example, the MyFeatureConfig configuration class will only be loaded if the property myapp.feature.enabled is set to true. If the property is not present or has a different value, the configuration class will be ignored during the application startup.