相关疑难解决方法(0)

eureka发现客户端 - 选择性禁用

有没有办法根据弹簧配置文件禁用spring-boot eureka客户端注册?

目前我使用以下注释:

@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableConfigServer

public class ConfigApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要的是一个条件如(借用伪代码)

@if (Profile!="development")
@EnableDiscoveryClient
@endif
Run Code Online (Sandbox Code Playgroud)

或者在应用程序属性文件中的某种方式.我已经尝试将application.yml文件设置为:

spring:
  profiles: development
  cloud:
    discovery:
      enabled: false
Run Code Online (Sandbox Code Playgroud)

但这没效果.

spring spring-boot netflix-eureka

16
推荐指数
6
解决办法
3万
查看次数

标签 统计

netflix-eureka ×1

spring ×1

spring-boot ×1