无法通过 spring.cloud.config.enabled:false 禁用 Spring Cloud Config

新手上路,请多包涵

让我先说我没有直接使用 Spring Cloud Config,它是通过 Spring Cloud Hystrix starter 传递的。

仅使用 @EnableHystrix 时,Spring Cloud 还尝试定位配置服务器,但预期不成功,因为我没有使用。据我所知,该应用程序运行良好,但问题在于状态检查。运行状况显示 DOWN 因为没有配置服务器。

浏览项目的源代码,我希望 spring.cloud.config.enabled=false 禁用此功能链,但这不是我所看到的。

升级到 1.0.0.RC1 (添加此属性)并使用 @EnableCircuitBreaker

 {
    status: "DOWN",
    discovery: {
        status: "DOWN",
        discoveryClient: {
            status: "DOWN",
            error: "org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.client.discovery.DiscoveryClient] is defined"
        }
    },
    diskSpace: {
        status: "UP",
        free: 358479622144,
        threshold: 10485760
    },
    hystrix: {
        status: "UP"
    },
    configServer: {
        status: "DOWN",
        error: "org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http: //localhost: 8888/bootstrap/default/master":Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect"
    }
}

检查 configprops 端点后, 似乎 我的属性被覆盖了。请注意,父级启用了 configClient。

 parent: {
    configClientProperties: {
        prefix: "spring.cloud.config",
        properties: {
            password: null,
            discovery: {
                enabled: false,
                serviceId: "CONFIGSERVER"
            },
            name: "bootstrap",
            label: "master",
            env: "default",
            uri: "http://localhost:8888",
            enabled: true,
            failFast: false,
            username: null
        }
    }
},
configClientProperties: {
    prefix: "spring.cloud.config",
    properties: {
        password: null,
        discovery: {
            enabled: false,
            serviceId: "CONFIGSERVER"
        },
        name: "bootstrap",
        label: "master",
        env: "default",
        uri: "http://localhost:8888",
        enabled: false,
        failFast: false,
        username: null
    }
}

如果我似乎没有正确执行此操作,任何方向都将不胜感激。

原文由 bvulaj 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1k
1 个回答

引导期间需要配置服务器,这就是父属性源的来源。看起来您需要做的就是将您的 spring.cloud.config.enabled 属性移动到 bootstrap.yml(或 .properties)。

原文由 Dave Syer 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题