一、简介
1.Apollo 是什么?Apollo(阿波罗)是携程框架部门研发的分布式配置中心。服务端基于Spring Boot和Spring Cloud开发。
2.为什么要使用Apollo?
安全性:配置跟随源代码保存在代码库中,容易造成配置泄漏时效性:普通方式配置,修改配置,需要重启服务才能生效局限性:无法支持动态调整:例如日志开关、功能开关
二、使用
1.引入jar包(版本号跟随springboot)
com.ctrip.framework.apollo apollo-client 1.4.02.启动类上加注解
@SpringBootApplication
@EnableApolloConfig
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
3.配置文件(重要)
apollo-env.properties:
不同环境的地址:当apollo地址改变时随之改变,任意改变将会无法连接apollo
#开发
dev.meta=http://10.30.2.214:8080
#测试
uat.meta=http://cc-conf-uat.hivoice.cn:8080
#线上
pro.meta=http://cc-conf-pro.hivoice.cn:8080
application.properties:
#这个意思是读取哪个后缀配置文件,我这里有两个配置文件一个是local一个是apollo
spring.profiles.active = apollo
application-apollo.properties:
apollo.bootstrap.enabled=true
apoll

本文介绍了携程框架部门研发的分布式配置中心Apollo,详细解释了为何选择使用Apollo及其带来的优势,包括安全性、时效性和灵活性等,并提供了具体的引入方法和配置步骤。
最低0.47元/天 解锁文章
4234

被折叠的 条评论
为什么被折叠?



