微服务配置中心 Apollo 解析——调试环境搭建

表结构
3. ConfigService && AdminService
=================================
同时启动 apollo-adminservice 和 apollo-configservice 项目,基于 apollo-assembly 项目来启动。
1、新建 IDEA Application

新建 Application
2、配置 IDEA Application

配置 Application
Main class :com.ctrip.framework.apollo.assembly.ApolloApplication 。
VM options :
-Dapollo_profile=github
-Dspring.datasource.url=jdbc:mysql://localhost:33061/ApolloConfigDB? characterEncoding=utf8
-Dspring.datasource.username=root
-Dspring.datasource.password=123456
-Dlogging.fi
le=/Users/yunai/apollo-assembly.log
spring.datasource 配置连接 ApolloConfigDB 数据库。
loggine.file 配置日志输出文件。
Use classpath of module :apollo-assembly 。
3、启动 IDEA Application

启动 Application
启动时间需要 3 分钟左右,请耐心等待。当打开 http://localhost:8080/ 看到 APOLLO-ADMINSERVICE 和 APOLLO-CONFIGSERVICE 注册到 Eureka 中,代表启动成功。

4. PortalService
=================
1、新建 IDEA Application
2、配置 IDEA Application

配置 Application
Main class :com.ctrip.framework.apollo.portal.PortalApplication 。
VM options :
-Dapollo_profile=github,auth
-Ddev_meta=http://localhost:8080/
-Dserver.port=8070
-Dspring.datasource.url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
-Dspring.datasource.username=root
-Dspring.datasource.password=
-Dlogging.file=/Users/yunai/apollo-portal.log
spring.datasource 配置连接 ApolloPortalDB 数据库。
loggine.file 配置日志输出文件。
Use classpath of module :apollo-portal 。
内置账号
username :Apollo
password :admin
3、启动 IDEA Application
启动时间很快。当打开 http://localhost:8070/ 。

5. Demo
========
考虑到下面的测试,需要创建测试的应用,编号为 100004458 。如下图所示:

100004458
1、新建 IDEA Application
2、配置 IDEA Application

配置 Application
Main class :com.ctrip.framework.apollo.demo.api.SimpleApolloConfigDemo 。
VM options :
-Denv=dev
-Ddev_meta=http://localhost:8080
Use classpath of module :apollo-demo 。
3、启动 IDEA Application
成功后,输出日志如下:
Apollo Config Demo. Please input key to get the value. Input quit to exit.
输入 "timeout" ,回车,输出如下:
timeout
[apollo-demo][main]2018-04-22 11:12:43,345 INFO [com.ctrip.framework.apollo.demo.api.SimpleApolloConfigDemo] Loading key : timeout with value: 6666
此处便是我们在 Apollo Portal 中配置的 "timeout" 值。
===作者:别掉头发了
评论