當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
bootstrap项目实例_SpringCloud Config 使用Git的应用实例
生活随笔
收集整理的這篇文章主要介紹了
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
- 下一篇: gradle idea java ssm