客户端使用分步骤:访问(:8070/)
第一步:创建项目
创建之后,如下图
具体查看使用指南传送门
上面不是我要说的重点,重点是如何在我们项目中使用,以broadway-gateway为例。
第一步:创建bootstrap.yml,在application.yml加载之前要加载配置属性
app: #重点关联,id必须是唯一的,每个service各自不同 id: P000000001 apollo: meta: :8080/ # apollo-configservice bootstrap: enabled: true namespaces: application
第二步:使用配置的变量
eureka: instance: prefer-ip-address: true client: service-url: # 冒号后面的baidu.com是默认值,如果无法连接apollo,可以使用默认值防止出错 defaultZone: ${broad.gateway.eureka.server-list:}运行gateway,可以看到如下结果:
2020-01-17 17:06:56.623 INFO 12444 --- [ main] c.c.f.f.i.p.DefaultApplicationProvider : App ID is set to P000000001 by app.id property from System Property 2020-01-17 17:06:56.634 INFO 12444 --- [ main] c.c.f.f.i.p.DefaultServerProvider : Environment is set to null. Because it is not available in either (1) JVM system property 'env', (2) OS env variable 'ENV' nor (3) property 'env' from the properties InputStream. 2020-01-17 17:06:56.711 INFO 12444 --- [ main] c.c.f.a.i.DefaultMetaServerProvider : Located meta services from apollo.meta configuration: :8080/! 2020-01-17 17:06:56.719 INFO 12444 --- [ main] c.c.f.apollo.core.MetaDomainConsts : Located meta server address :8080/ for env UNKNOWN from com.ctrip.framework.apollo.internals.DefaultMetaServerProvider 2020-01-17 17:06:57.761 INFO 12444 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$bc952272] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=http://www.likecs.com/_/_/_/ :: Spring Boot :: (v2.1.10.RELEASE) ...可以看到,在springboot启动之前,apollo首先加载配置信息了~