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

 周白行_170 发布于 2022-12-04 14:23

让我先说明我没有直接使用Spring Cloud Config,它可以通过Spring Cloud Hystrix入门传递.

仅使用时@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
    }
}

任何方向都会受到赞赏,如果看起来我没有正确地做到这一点.

3 个回答
  • 您可以将引导属性或yml放入资源目录或应用程序目录并添加 spring.cloud.config.enabled=false.要么

    您可以通过添加环境变量来禁用spring cloud配置服务器客户端:SPRING_CLOUD_CONFIG_ENABLED=falseOR

    如果将参数传递给SpringApplication.run,则可以通过向应用程序添加参数来禁用配置服务器客户端:

    public static void main(String[] args) throws Exception { SpringApplication.run(YourApplication.class, args); }

    并启动应用程序:

    java -jar yourapplication.jar --spring.cloud.config.enabled=false

    2022-12-11 02:05 回答
  • 我遇到了同样的问题,我想禁用配置服务器(因为到目前为止我们不需要它),但至少RC1上面提到的属性是不正确的.

    spring.cloud.enabled
    

    应该:

    spring.cloud.config.enabled
    

    2022-12-11 02:57 回答
  • 引导期间需要配置服务器,这是父属性源的来源.看起来你需要做的就是将你的spring.cloud.config.enabled属性移动到bootstrap.yml(或.properties).

    2022-12-11 03:11 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有