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

问题描述 投票:0回答:1

我正在尝试访问Spring Cloud配置服务器,但它已关闭。我仍然想使用本地application.properties测试应用程序。有什么办法可以做到吗?

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

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

我正在追随例外

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]

java spring spring-boot spring-cloud spring-cloud-config
1个回答
0
投票

要禁用spring-cloud-config您并使用您的本地属性,您需要将此属性添加到bootstrap.yml

spring.cloud.config.enabled=false

然后仅在需要通过应用程序args运行应用程序时启用它,如下所示:

java -jar your-application-name.jar --spring.cloud.config.enabled=true
© www.soinside.com 2019 - 2024. All rights reserved.