今天给大家介绍一下如何进行apollo的简单使用。文章的内容小编觉得不错,现在给大家分享一下,觉得有需要的朋友可以了解一下,希望对大家有所帮助,下面跟着小编的思路一起来阅读吧。
阿波罗是个同步配置工具跟springcloud的远程git库config拉取配置类似。
链接: https://pan.baidu.com/s/1tIWZlve9duCeOx0RpqSCdg 提取码: gqvr
主要就是启动脚本得改下 demo.sh 里边
#这俩数据库得创建上(你把下载下的项目中2数据库导入)
# apollo config db info
apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=manager
apollo_config_db_password=123
# apollo portal db info
apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=manager
apollo_portal_db_password=123
#脚本demo.sh 的checkServerAlive方法这里max_counter24我改为50了不然启动时间太短起不来。
function checkServerAlive {
declare -i counter=0
declare -i max_counter=50 # 24*5=120s
declare -i total_time=0
sh ./demo start|stop #起停服务
sh ./demo client #启动demo # 输入timeout返回时间,输入quit退出
默认启动了3个端口8070|8080|8090
portal页面
http://localhost:8070/
默认账号:apollo密码:admin
点击sampleapp进入demo项目同步配置
点击修改 、发布、发现demo变为修改的配置,同步到demo配置端
参考:https://github.com/ctripcorp/apollo/wiki/Java%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97#3213-spring-boot%E9%9B%86%E6%88%90%E6%96%B9%E5%BC%8F%E6%8E%A8%E8%8D%90
<!--apollo配置-->
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.5.1</version>
</dependency>
app:
id: SampleApp #项目id(服务端指定的)
apollo:
meta: http://localhost:8080 #项目服务端地址
server:
port: 8010 #自己项目端口
package top.heliming.tomcat7war;
//import org.junit.Test;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Tomcat7warApplicationTests {
@Test
void contextLoads() {
Config appConfig = ConfigService.getAppConfig();
String property = appConfig.getProperty("timeout", "0");
System.out.println(property);
}
}
以上就是如何进行apollo的简单使用的全部内容了,更多与如何进行apollo的简单使用相关的内容可以搜索亿速云之前的文章或者浏览下面的文章进行学习哈!相信小编会给大家增添更多知识,希望大家能够支持一下亿速云!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/u/3730149/blog/4651941