當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringBoot快速集成Apollo配置中心
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot快速集成Apollo配置中心
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.引入依賴
? ? ? ?<dependency><groupId>com.ctrip.framework.apollo</groupId><artifactId>apollo-client</artifactId><version>1.3.0</version></dependency>2.添加配置
# ? app.id:AppId是應用的身份信息,是配置中心獲取配置的一個重要信息。 # ? apollo.bootstrap.enabled:在應用啟動階段,向Spring容器注入被托管的application.properties文件的配置信息。 # ? apollo.bootstrap.eagerLoad.enabled:將Apollo配置加載提到初始化日志系統之前。 # ? my.test: 等等演示讀取Apollo中的配置 ? server:port: 8761 ? app:id: springboot-apollo apollo:meta: http://127.0.0.1:8080bootstrap:enabled: trueeagerLoad:enabled: truemy:test: 13.測試類
@RestController public class HelloController {@Value("${my.test}")String test; ?@GetMapping("hi")public String hi(String name) {System.out.println("name:" + name);return test + ":"+name;} ? }4.Apollo配置
?
5.測試
啟動項目,訪問http://localhost:8761/hi?name=yfy
?
可以看到讀取到了apollo中的對應配置。
總結
以上是生活随笔為你收集整理的SpringBoot快速集成Apollo配置中心的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Apollo分布式配置中心在java的简
- 下一篇: Apollo之灰度发布