How to selectively disable Eureka discovery client with Spring?

前端 未结 6 1413
一整个雨季
一整个雨季 2020-12-09 03:12

Is there a way to disable spring-boot eureka client registration based on the spring profile?

Currently I use the following annotations:

@Configurati         


        
6条回答
  •  清歌不尽
    2020-12-09 03:56

    Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:

    @Profile("!development")
    @Configuration
    @EnableDiscoveryClient
    public class EurekaClientConfiguration {
    }
    

    It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".

    Hope that helps,

提交回复
热议问题