bootstrap文件介绍
bootstrap的中文翻译是“引导程序”的意思。Spring中的ApplicationContext是会有父子关系的。Spring Cloud初始化的ApplicationContext叫bootstrap ApplicationContext,之后会创建一些子的ApplicationContext。这个bootstrap ApplicationContext如果在初始化的过程中是可以接收一些外部属性控制的,那么对应的属性需要配置在bootstrap.yml或bootstrap.properties文件中。默认会在Classpath的根路径或config路径下寻找它们。ApplicationContext是有父子关系的,那依托于ApplicationContext的Environment也相当于间接的有了父子关系,所以定义在bootstrap.yml文件中的属性值也可以被我们自己定义的bean使用。只是它里面的值会被我们定义在application.yml中的相同属性的值覆盖掉。bootstrap ApplicationContext寻找的外部属性文件的名字不一定是bootstrap,它可以通过系统属性spring.cloud.bootstrap.name
进行指定,比如通过系统属性spring.cloud.bootstrap.name
指定bootstrap属性文件的名称是application,即会在Classpath根目录或config目录下寻找application.yml或application.properties文件。也可以通过系统属性spring.cloud.bootstrap.location
指定bootstrap文件的位置,它们的用法就类似于Spring Boot中指定配置文件的spring.config.name
和spring.config.location`。
如果在bootstrap.yml中指定了
spring.profiles.active=dev
,则bootstrap ApplicationContext寻找配置文件时还会寻找bootstrap-dev.yml文件。
如果有需要我们也需要在bootstrap ApplicationContext中做一些事情,比如定义一些bean等,则我们也可以定义一个使用@Configuration
标注的Class,然后在Classpath下的META-INF/spring.factories
文件中通过org.springframework.cloud.bootstrap.BootstrapConfiguration
属性指定@Configuration
类的名称。比如下面这样一个@Configuration
类。
@Configuration
public class BootstrapConfiguration {
@Bean
public TestService testService() {
return new TestService();
}
}
那么在spring.factories
文件中需要这样定义。
org.springframework.cloud.bootstrap.BootstrapConfiguration=com.elim.learn.spring.cloud.config.client.BootstrapConfiguration
(注:本文是基于Spring Cloud Finchley.SR1所写)
相关推荐
前端框架利器——bootstrap
spring cloud 是基于Spring Cloud的云分布式后台管理系统架构,核心技术采用Eureka、Fegin、Ribbon、Zuul、Hystrix、Security、OAth、Mybatis、Ace-cache等主要框架和中间件,UI采用Bootstrap、jquery等前端组件 ...
综合spring mvc + spring + hibernate + bootstrap开发图书管理系统
JavaWeb旅游网站——BootStrap响应式布局 环境: mysql 8.0 jdk 1.8 tomcat 9 redis 2.9.8 主要功能:用户登录、用户注册、修改密码、旅游路线搜索、旅游线路收藏、线路收藏排行榜
启动git远程配置中心需要修改springcloud-producer项目的bootstrap.yml配置文件,并将配置配件上传到git上。 3、springcloud-zipkin。 4、 springcloud-producer。 5、springcloud-consumer。 6、springcloud-...
spring mvc+spring+hibernate+bootstrap+mysql 考勤及薪酬管理系统
spring mvc+spring+hibernaate+bootstrap+maven通用后台部门员工管理系统.zip
SpringCloud微服务课程说明 1 网站架构演变过程 1 传统架构 1 分布式架构 1 SOA架构 1 微服务架构 2 微服务架构产生的原因 2 漫谈微服务架构 2 什么是微服务 2 微服务架构特征 3 微服务架构如何拆分 3 ...
基于spring mvc、spring、hibernate、bootstrap、maen开发的企业级项目,导入即可运行
Spring mvc tiles thinAdmin bootstrap Spring mvc tiles thinAdmin bootstrap Spring mvc tiles thinAdmin bootstrap
本人平时学习的宝贝,都是精华,适合初学者,现送给大家
本系统前端界面修改自若依bootstrap前端框架,后台使用springboot,...同时本系统是springcloud中的一个后台管理项目,还可以开发ERP,CRM,OA等系统,基于springcloud的调用方式,可以方便的在各系系统之间进行通信。
used as an API gateway and proxy for Spring Cloud applications: Spring Cloud Netlix Zuul and Spring Cloud Gateway. You will learn how to integrate them with service discovery and create simple and ...
Mastering Spring Cloud Packt Upsell Why subscribe? PacktPub.com Contributors About the author About the reviewer Packt is searching for authors like you Preface Who this book is for What this book ...
基于Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现,内含有可直接运行的源代码以及数据库文件。由于项目中jar包过大,所以将源代码放在了百度网盘中,请根据文件中的链接以及提取码,下载源码。
基于Spring+SpringMAC+Bootstrap大型金融项目实战视频
Day02:Maven基础与SpringCloud核心组件.rar0[:F.D#m;b9T Day03:学习Mybatis框架与搭建代码生成器.rar Day04:vueCli与bootstrap开发后台管理页面.rar Day05:Vue与Mybatis开发前端主要页面.rar3I'H2y6}7\!i/L+d Day06:...
spring mvc+bootstrap实现文件的上传实例,文件可拖拽选择和多选。