温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何进行apollo的简单使用

发布时间:2022-01-18 11:39:14 来源:亿速云 阅读:353 作者:柒染 栏目:大数据

今天给大家介绍一下如何进行apollo的简单使用。文章的内容小编觉得不错,现在给大家分享一下,觉得有需要的朋友可以了解一下,希望对大家有所帮助,下面跟着小编的思路一起来阅读吧。

阿波罗是个同步配置工具跟springcloud的远程git库config拉取配置类似。

快速启动:最终用一下的zip包启动起来了,用1.7无法启动

如何进行apollo的简单使用

下载
链接: https://pan.baidu.com/s/1tIWZlve9duCeOx0RpqSCdg 提取码: gqvr
修改下载的zip包解压后的配置,导入数据
主要就是启动脚本得改下
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
启停服务端 登录portal
sh ./demo start|stop #起停服务
sh ./demo client #启动demo # 输入timeout返回时间,输入quit退出
默认启动了3个端口8070|8080|8090
portal页面
http://localhost:8070/

默认账号:apollo密码:admin
修改配置

如何进行apollo的简单使用

点击sampleapp进入demo项目同步配置

如何进行apollo的简单使用

点击修改 、发布、发现demo变为修改的配置,同步到demo配置端

springboot项目简单集成

参考: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

导入maven依赖

        <!--apollo配置-->
        <dependency>
            <groupId>com.ctrip.framework.apollo</groupId>
            <artifactId>apollo-client</artifactId>
            <version>1.5.1</version>
        </dependency>

yml配置

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的简单使用的全部内容了,更多与如何进行apollo的简单使用相关的内容可以搜索亿速云之前的文章或者浏览下面的文章进行学习哈!相信小编会给大家增添更多知识,希望大家能够支持一下亿速云!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI