当前位置:
首页 >
bootstrap项目实例_SpringCloud Config 使用Git的应用实例
发布时间:2025/3/20
30
豆豆
生活随笔
收集整理的这篇文章主要介绍了
bootstrap项目实例_SpringCloud Config 使用Git的应用实例
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
如何分门别类的放置yml文件,被多个工程引用,避免全部堆积在一个application.yml中
一、config-server
项目依赖:
implementation('org.springframework.cloud:spring-cloud-config-server')Spring Cloud Config Server为外部配置提供了一个基于HTTP资源的API。通过使用@EnableConfigServer注释,服务器可嵌入到Spring Boot应用程序中。因此,以下应用程序是配置服务器:
@SpringBootApplication@EnableConfigServerpublic class ConfigServer { public static void main(String[] args) { SpringApplication.run(ConfigServer.class, args); }}application.yml配置方案之一:
spring:cloud:config:server:git:uri: ${GIT_URL:http://xxxx/xxxx/xxx/gityml.git}username: userpassword: passwdsearchPaths: '**/*'二、gityml仓库配置图解
注意:yml文件名称,application.yml代表公共的,所有项目都会获取
三、SpringBoot项目配置实例
项目依赖:
implementation('org.springframework.cloud:spring-cloud-starter-config')bootstrap.yml配置:
spring:cloud:config:uri: ${CONFIG_SERVER_URL:http://system-service-config} #配置服务的访问地址fail-fast: true #链接不上配置中心,则停止服务label: ${GIT_LABEL:dev} #(git项目分支名称) 环境配置 不同环境使用不同配置,默认是开发环境总结
以上是生活随笔为你收集整理的bootstrap项目实例_SpringCloud Config 使用Git的应用实例的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: maven netty 配置_Sprin
- 下一篇: js中当等于最小值是让代码不执行_网页中