简体   繁体   English

如果配置服务器关闭,Spring Cloud 配置客户端会加载本地属性

[英]Spring cloud config client load local properties if the config server is down

I am trying to access the spring cloud config server but it is down.我正在尝试访问 spring 云配置服务器,但它已关闭。 I still want to test the application using local application.properties .我仍然想使用本地application.properties测试应用程序 Is there any way i could do this?有什么办法可以做到这一点吗?

pom.xml pom.xml

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

bootstrap.yml引导程序.yml

server:
  port: 8086
spring:
  application:
    name: PromoMS
  security:
    basic:
      enabled: false
    management:
      security:
        enabled: false
  cloud:
    config:
      fail-fast: true
      discovery:
        enabled: true
        service-id: ms-config-server

I am getting following exception我收到以下异常

java.lang.IllegalStateException: No instances found of configserver (ms-config-server)
    at org.springframework.cloud.config.client.ConfigServerInstanceProvider.getConfigServerInstances(ConfigServerInstanceProvider.java:48) ~[spring-cloud-config-client-2.2.2.RELEASE.jar:2.2.2.RELEASE]

To disable spring-cloud-config you and use your local properties, you need to add this property to your bootstrap.yml :要禁用 spring-cloud-config 并使用本地属性,您需要将此属性添加到bootstrap.yml

spring.cloud.config.enabled=false

And then enable it only when you need to run your application via application args, something like this:然后仅当您需要通过应用程序参数运行应用程序时才启用它,如下所示:

java -jar your-application-name.jar --spring.cloud.config.enabled=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring boot config客户端无法使用bootstrap.properties从配置服务器加载配置 - spring boot config client could not load configuration from config server using bootstrap.properties Spring Cloud Config:以编程方式定义服务器配置属性 - Spring Cloud Config: define server config properties programmatically 当 Spring Security 在 Spring Cloud Config Server 上处于活动状态时,Spring Cloud Config Client 不获取配置 - Spring Cloud Config Client not fetching config when Spring Security is active on Spring Cloud Config Server Spring Cloud Config客户端是否也可以从其本地加载属性? - Is there a possibility that spring cloud config clients can load properties from their local as well? Spring cloud config 从 AWS S3 加载客户端 bootstrap.properties - Spring cloud config load client bootstrap.properties from AWS S3 Spring Cloud - 配置客户端会降低指标/运行状况 - Spring Cloud - Config Client slows down metric /health Spring Cloud Config-属性解密在客户端不起作用 - Spring Cloud Config- Decryption of properties is not working on Client Side Spring 云配置客户端应用程序未使用 bootstrap.properties - Spring Cloud Config Client app not using bootstrap.properties Spring Cloud Config客户端配置刷新不起作用 - spring cloud config client config refresh not working 保存从Spring Cloud Config Server下载的属性 - Save Properties Downloaded from Spring Cloud Config Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM