1

I'm using several profiles for my app, that I can select via the application.yml prop:

spring.profiles.active: dev #can be integration, uat, prod

My applications all start by:

@SpringBootApplication
@EnableEurekaClient
public class MyApp {
}

Now, I'd like to enable the eureka client only for selected profiles. I don't want, for example, to enable that in dev profile as in dev you don't mind about the service register right?

Is it possible? I tried to move eureka related properties in the single profile files but they are found anyway...

Phate
  • 6,066
  • 15
  • 73
  • 138
  • Possible duplicate of [eureka discovery client - selective disable](https://stackoverflow.com/questions/35142105/eureka-discovery-client-selective-disable) – narendra-choudhary May 20 '18 at 15:56

1 Answers1

4

you can extract your config and only activate it on certain profiles

@Configuration
@Profile(value= {"uat","prod"})
@EnableEurekaClient
public class EurekaClientConfiguration {
   //your configuration
}

on the other hand you could de-activate config for a certain profile by using a ! (=not) @Profile("!dev")

Dirk Deyne
  • 6,048
  • 1
  • 15
  • 32