這篇文章主要為大家展示了“apollo如何搭建本地開發(fā)環(huán)境”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“apollo如何搭建本地開發(fā)環(huán)境”這篇文章吧。

10余年的鎮(zhèn)坪網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整鎮(zhèn)坪建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“鎮(zhèn)坪網(wǎng)站設(shè)計(jì)”,“鎮(zhèn)坪網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
開源配置中心 - Apollo
Apollo(阿波羅)是攜程框架部門研發(fā)的配置管理平臺(tái),能夠集中化管理應(yīng)用不同環(huán)境、不同集群的配置,配置修改后能夠?qū)崟r(shí)推送到應(yīng)用端,并且具備規(guī)范的權(quán)限、流程治理等特性。服務(wù)端基于Spring Boot和Spring Cloud開發(fā),打包后可以直接運(yùn)行,不需要額外安裝Tomcat等應(yīng)用容器。
檢出代碼
apollo github
可以fork下然后本地使用idea打開
數(shù)據(jù)庫(kù)腳本
執(zhí)行以下腳本創(chuàng)建ApolloConifgDB、ApolloPortalDB
apollo.scripts.sql.apolloconfigdb.sql
apollo.scripts.sql.apolloportaldb.sql
啟動(dòng)configservice adminservice
Main class配置
com.ctrip.framework.apollo.assembly.ApolloApplication
VM opions
-Dapollo_profile=github -Dspring.datasource.url=jdbc:MySQL://localhost:3306/ApolloConfigDB?characterEncoding=utf8 -Dspring.datasource.username=root -Dspring.datasource.password= Program arguments --configservice --adminservice
啟動(dòng)完后,打開 http://localhost:8080可以看到apollo-configservice和apollo-adminservice都已經(jīng)啟動(dòng)完成并注冊(cè)到Eureka
啟動(dòng)Apollo-Portal
Main class配置
com.ctrip.framework.apollo.portal.PortalApplication -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=
如果啟用了auth profile的話,默認(rèn)的用戶名是apollo,密碼是admin
應(yīng)用在SIT、UAT、生產(chǎn)環(huán)境機(jī)器上
1.新增目錄/opt/data/目錄,且有可讀寫權(quán)限;
2.新增文件:/opt/settings/server.properties 且加入配置:
env=DEV sit: env=FAT uat: env=UAT 生產(chǎn):env=PRO
客戶端例子
@Component 設(shè)置組件名稱
@RefreshScope 指定配置改變可以刷新
@ConfigurationProperties(prefix = "redis.cache")
@Component("sampleRedisConfig")
@RefreshScope
public class SampleRedisConfig {
private static final Logger logger = LoggerFactory.getLogger(SampleRedisConfig.class);
private int expireSeconds;
private String clusterNodes;
private int commandTimeout;
private Map<String, String> someMap = Maps.newLinkedHashMap();
private List<String> someList = Lists.newLinkedList();
@PostConstruct
private void initialize() {
logger.info(
"SampleRedisConfig initialized - expireSeconds: {}, clusterNodes: {}, commandTimeout: {}, someMap: {}, someList: {}",
expireSeconds, clusterNodes, commandTimeout, someMap, someList);
}
public void setExpireSeconds(int expireSeconds) {
this.expireSeconds = expireSeconds;
}
public void setClusterNodes(String clusterNodes) {
this.clusterNodes = clusterNodes;
}
public void setCommandTimeout(int commandTimeout) {
this.commandTimeout = commandTimeout;
}
public Map<String, String> getSomeMap() {
return someMap;
}
public List<String> getSomeList() {
return someList;
}
@Override
public String toString() {
return String.format(
"[SampleRedisConfig] expireSeconds: %d, clusterNodes: %s, commandTimeout: %d, someMap: %s, someList: %s",
expireSeconds, clusterNodes, commandTimeout, someMap, someList);
}
}設(shè)置監(jiān)聽
@Component
public class SpringBootApolloRefreshConfig {
private static final Logger logger = LoggerFactory.getLogger(SpringBootApolloRefreshConfig.class);
@Autowired
private ApolloRefreshConfig apolloRefreshConfig;
@Autowired
private SampleRedisConfig sampleRedisConfig;
@Autowired
private RefreshScope refreshScope;
@ApolloConfigChangeListener
public void onChange(ConfigChangeEvent changeEvent) {
logger.info("before refresh {}", sampleRedisConfig.toString());
refreshScope.refresh("sampleRedisConfig");
logger.info("after refresh {}", sampleRedisConfig.toString());
}
}以上是“apollo如何搭建本地開發(fā)環(huán)境”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
新聞名稱:apollo如何搭建本地開發(fā)環(huán)境
文章源于:http://www.jbt999.com/article38/pdggpp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、網(wǎng)站導(dǎo)航、全網(wǎng)營(yíng)銷推廣、做網(wǎng)站、自適應(yīng)網(wǎng)站、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)