[英]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.