本地开发模式下的 Spring Cloud 配置 [英] Spring cloud config in local dev mode

查看:34
本文介绍了本地开发模式下的 Spring Cloud 配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以根据配置文件控制应用程序是否需要 spring-config-server.

Is it possible to control if the application requires spring-config-server based on profile.

我想从资源/...中选择本地开发配置文件中的属性,并且仅将 cloud-config 用于配置服务器运行的配置文件.

I want to pick properties from resource/... in say local-dev profile and use cloud-config only with a profile where there would be a config-server running.

推荐答案

您可以禁用对特定配置文件使用 config-server.请尝试在 bootstrap.yml 中定义属性,如下所示.请注意,我们应该只在 bootstrap.yml 中配置这些设置.在 application.yml 中设置这些属性将不起作用.在这种情况下,local 配置文件将仅与/resources 文件夹中的本地配置文件一起运行.在 dev 配置文件中,来自 config-server 的属性将覆盖来自 resources/文件夹的属性.

You can disable using config-server for a specific profile. Please try to define the properties in bootstrap.yml like below. Please note, we should configure these settings only in bootstrap.yml. Setting these properties in application.yml will not work. In this case, local profile will be running only with local profiles in /resources folder. In dev profile, properties from config-server will override properties from resources/ folder.

spring:
  profiles: local
  cloud:
    config:
      enabled: false
---
spring:
  profiles: dev
  cloud:
    config:
      uri: http://<your config server>

这篇关于本地开发模式下的 Spring Cloud 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆