其实yml和properties文件是同样的原理,且一个项目上要么yml或者properties,二选一的存在。git
推荐使用yml,更简洁。spring
bootstrap与application
1.加载顺序
这里主要是说明application和bootstrap的加载顺序。bootstrap
bootstrap.yml(bootstrap.properties)先加载
application.yml(application.properties)后加载
bootstrap.yml 用于应用程序上下文的引导阶段。app
bootstrap.yml 由父Spring ApplicationContext加载。加密
父ApplicationContext 被加载到使用 application.yml 的以前。.net
2.配置区别
bootstrap.yml 和application.yml 均可以用来配置参数。server
bootstrap.yml 能够理解成系统级别的一些参数配置,这些参数通常是不会变更的。
application.yml 能够用来定义应用级别的,若是搭配 spring-cloud-config 使用 application.yml 里面定义的文件能够实现动态替换。
使用Spring Cloud Config Server时,应在 bootstrap.yml 中指定:blog
spring.application.name
spring.cloud.config.server.git.uri
一些加密/解密信息
实例:ip
bootstrap.ymlit
spring: application: name: service-a cloud: config: uri: http://127.0.0.1:8888 fail-fast: true username: user password: ${CONFIG_SERVER_PASSWORD:password} retry: initial-interval: 2000 max-interval: 10000 multiplier: 2 max-attempts: 10--------------------- 原文:https://blog.csdn.net/jeikerxiao/article/details/78914132