🔎这里是【秒懂·云原生】,关注我学习云原生不迷路
👍如果对你有帮助,给博主一个免费的点赞以示鼓励
欢迎各位🔎点赞👍评论收藏⭐️
👀专栏介绍
【秒懂·云原生】 目前主要更新微服务,一起学习一起进步。
👀本期介绍
主要介绍什么是Spring Cloud架构、Spring Cloud的组成及Spring Cloud的五大组件
文章目录
🍖Bootstrap 上下文
bootstrap.yml
spring:
application:
name: foo
cloud:
config:
uri: ${SPRING_CONFIG_URI:http://localhost:8888}
🍖应用上下文层级
🍖更改Bootstrap属性的位置
🍖重载远程属性
spring:
cloud:
config:
overrideNone: true #本地属性覆盖所有的远程属性源
overrideSystemProperties: false#仅覆盖远程属性源中的系统属性和环境变量
🍖自定义Bootstrap配置
🍖自定义Bootstrap属性源
@Configuration
public class CustomPropertySourceLocator implements PropertySourceLocator {
@Override
public PropertySource<?> locate(Environment environment) {
return new MapPropertySource("customProperty",
Collections.<String, Object>singletonMap("property.from.sample.custom.source", "worked as intended"));
}
}
org.springframework.cloud.bootstrap.BootstrapConfiguration=sample.custom.CustomPropertySourceLocator
上述配置令应用程序可以使用CustomPropertySourceLocator作为其属性源。
🍖日志记录配置
如果要使用Spring Boot配置日志设置,则应将此配置放在‘bootstrap.[yml | properties]’,如果你希望它适用于所有事件。
🍖Environment变化
- 重新绑定所有的@ConfigurationProperties的Bean实例,更新本地的配置属性。
- ·为在logging.level.*的所有属性设置日志的等级。