Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use apollo simply

Shulou Source: shulou.com Published: 2022-06-01 00:26:32 09月10日 Update

Today I will show you how to use apollo easily. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

Apollo is a synchronous configuration tool similar to springcloud's remote git library config pull configuration.

Quick start: finally started with the zip package, but could not be started with 1.7

Download link: https://pan.baidu.com/s/1tIWZlve9duCeOx0RpqSCdg extraction code: gqvr modifies the configuration of the downloaded zip package after decompression Importing data is mainly about starting scripts that need to be changed in demo.sh. # these two databases have to be created (you import 2 databases in the downloaded project) # apollo config db infoapollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8apollo_config_db_username=managerapollo_config_db_password=123# apollo portal db infoapollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8apollo_portal_db_username=managerapollo_portal_db_password=123# script Demo.sh checkServerAlive method here I changed the max_counter24 to 50, otherwise the startup time is too short to get up. Function checkServerAlive {declare-I counter=0 declare-I max_counter=50 # 2405remote 120s declare-I total_time=0 start and stop server login portalsh. / demo start | stop # start and stop service sh. / demo client # start demo # enter timeout return time, enter quit exit default starts 3 ports 8070 | 8080 | 8090portal page default account: apollo password: admin modify configuration

Click sampleapp to enter the demo project synchronization configuration

Click modify, publish, and discover that the demo has changed to the modified configuration, and synchronize to the demo configuration.

Simple integration of springboot project

Reference: 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

Import maven dependencies

Com.ctrip.framework.apollo apollo-client 1.5.1

Yml configuration

App: id: SampleApp # Project id (specified by the server) apollo: meta: http://localhost:8080 # Project Server address server: port: 8010 # own project port

Code modification test pull configuration

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;@SpringBootTestclass Tomcat7warApplicationTests {@ Test void contextLoads () {Config appConfig = ConfigService.getAppConfig (); String property = appConfig.getProperty ("timeout", "0"); System.out.println (property);}}

These are all the contents of how to use apollo simply. You can search the previous articles or browse the following articles to learn more about how to use apollo. I believe the editor will add more knowledge to you. I hope you can support it!

Tags: Configuration project service content data article synchronization that is database time more port script input good code address password tool idea 报价宝 降噪耳机价格 耳机价格 红米手机价格 华为手机价格 小米手机价格 电视机价格 笔记本电脑价格 笔记本价格 汽车价格 Xiaomi Linux Shulou Tech Info Shulou Technology macOS