Spring Cloud 参考文档(嵌入Config Server)

嵌入Config Server

Config Server做为独立应用程序运行最佳,可是,若是须要,你能够将其嵌入另外一个应用程序中,为此,请使用@EnableConfigServer注解。在这种状况下,名为spring.cloud.config.server.bootstrap的可选属性很是有用,它是一个标志,指示服务器是否应从其本身的远程存储库配置自身,默认状况下,该标志处于关闭状态,由于它可能会延迟启动。可是,当嵌入到另外一个应用程序中时,以与任何其余应用程序相同的方式初始化是有意义的,将spring.cloud.config.server.bootstrap设置为true时,还必须使用组合环境存储库配置,例如:spring

spring:
  application:
    name: configserver
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
          - type: native
            search-locations: ${HOME}/Desktop/config
        bootstrap: true
若是使用bootstrap标志,则配置服务器须要在 bootstrap.yml中配置其名称和存储库URI。

要更改服务器端点的位置,你能够(可选)设置spring.cloud.config.server.prefix(例如,/config),以便在前缀下提供资源,前缀应该开始但不以/结束,它应用于Config Server中的@RequestMappings(即Spring Boot server.servletPathserver.contextPath前缀下面)。bootstrap

若是要直接从后端存储库(而不是从配置服务器)读取应用程序的配置,你基本上须要一个没有端点的嵌入式配置服务器,你能够经过不使用@EnableConfigServer注解彻底关闭端点(设置spring.cloud.config.server.bootstrap=true)。segmentfault


上一篇:提供纯文本配置访问

下一篇:推送通知和Spring Cloud Bus

相关文章
相关标签/搜索