springboot整合apollo

0. linux中搭建apollo:

       https://blog.csdn.net/qq_34707456/article/details/103702828

1.maven依赖

  <!--apollo客户端依赖     -->
        <dependency>
            <groupId>com.ctrip.framework.apollo</groupId>
            <artifactId>apollo-client</artifactId>
            <version>1.4.0</version>
        </dependency>

 

2.application.yml配置

#apollo相关配置
app:
  #项目的app-id
  id: 19970322
apollo:
  #configservice服务地址
  meta: http://39.108.107.163:8002
  bootstrap:
    enabled: true
    eagerLoad:
      enabled: true

 

3.通过配置文件来指定env=YOUR-ENVIRONMENT

对于Mac/Linux,文件位置为 /opt/settings/server.properties
对于Windows,文件位置为 C:\opt\settings\server.properties
目前,env支持以下几个值(大小写不敏感):
DEV, FAT, UAT, PRO
 

4.启动类上加@EnableApolloConfig

 

5.如果apollo服务端再linux上部署,本地为windows连接则需要配置jvm启动参数

地址为:configservice服务地址

-Dapollo.configService=http://39.108.107.163:8002

 

 

6.测试

  服务端发布一个配置

 

springboot中通过@Value来获取

  @Value("${test:test}")
    private String  test;

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值