0

I would like to have @EnableReactiveElasticsearchRepositories enabled only when the specific profile is present.

In Kotlin Bean DSL I can define the following condition:

    environment(
        { activeProfiles.contains("local") },
        {
            bean<...>()
            // ...
        }
    )

I would like to have the same condition when @EnableReactiveElasticsearchRepositories is present.

pixel
  • 24,905
  • 36
  • 149
  • 251

1 Answers1

1

You can create a separate configuration class and use the @Profile annotation to inject it only for a requested profile, like this.

@Profile("prod")
@EnableReactiveElasticsearchRepositories
@Configuration
class SomeConfig {
    @PostConstruct
    fun init() {
        println("I'm here!")
    }
}
Ice
  • 1,783
  • 4
  • 26
  • 52