オープンソース構成センター-Apollo
Apolloは、Ctripのフレームワーク部門によって開発された構成管理プラットフォームです。さまざまな環境とアプリケーションのクラスターの構成を中央に管理できます。構成変更後、リアルタイムでアプリケーション側にプッシュでき、標準化された権限、プロセスガバナンス、その他の特性を備えています。サーバーは、スプリングブートとスプリングクラウドに基づいて開発されています。パッケージングの直後に実行でき、Tomcatなどの追加のアプリケーションコンテナをインストールする必要はありません。
コードをチェックしてください
Apollo Github
アイデアを使用してローカルに開くことができます
データベーススクリプト
次のスクリプトを実行して、apolloconifgdb、apolloportaldbを作成します
ConfigService Adminserviceを開始します
メインクラス構成
com.ctrip.framework.apollo.assembly.apolloapplication
VM意見
-dapollo_profile = github -dspring.datasource.url = jdbc:mysql:// localhost:3306/apolloconfigdb?charatereCoding = utf8 -dspring.datasource.username = root -dspring.datasource.parguments.pardword -dspring
開始後、http:// localhost:8080を開くと、apollo-configserviceとapollo-adminserviceの両方がEurekaに開始および登録されていることがわかります。
Apollo-Portalを開始します
メインクラス構成
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?charaterecoding = utf8 -dspring.datasource.username = root -dspring.datasource.password =
AUTHプロファイルが有効になっている場合、デフォルトのユーザー名はApolloであり、パスワードは管理者です
SIT、UAT、生産環境マシンに適用されます
1.ディレクトリ/Opt/Data/Directoryを追加すると、許可を読み取りおよび書き留めます。
2。新しいファイル:/opt/settings/server.propertiesを追加し、構成を追加しました:
env = devsit:env = fatuat:env = uat生産:env = pro
クライアントの例
@Component SETコンポーネント名@REFRESHSCOPE構成の変更は@configurationProperties(freix = "redis.cache") @component( "sampleredisconfig") @refreshscopepublic sampleredisconfig {private static final logger logger = loggeractory.getory.getoryfactory.getlogger(sampleredisconfig.class); Private int expireseconds;プライベート文字列clusternodes; private int commandtimeout;プライベートマップ<文字列、string> somemap = maps.newlinkedhashmap();プライベートリスト<String> SomeList = lists.NewLinkedList(); @postconstruct private void initialize(){logger.info( "sampleredisconfig initialized -expireseconds:{}、clusternodes:{}、commandtimeout:{}、somemap:{}、somelet:{}"、expreseconds、clusternodes、commandtime、commandtime、commap、 } public void setExpireconds(int expireconds){this.expireconds = expireconds; } 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、somemap、somerist); }}監視をセットアップします
@componentPublic Class SpringBootOlloreFreshConfig {private static final logger logger = loggerFactory.getLogger(SpringBootolloreFreshConfig.class); @autowired private apollorefreshconfig apollorefreshconfig; @autowired private sampleredisconfig sampleredisconfig; @Autowired Private Refreshscope Reshscope; @apolloconfigchangelistener public void onchange(configchangeEvent changeEvent){logger.info( "before refresh {}"、sampleredisconfig.toString()); shleadscope.refresh( "sampleredisconfig"); logger.info( "affery refresh {}"、sampleredisconfig.toString()); }}要約します
上記は、スプリングクラウドアポロアポロローカル開発環境建設プロセスがお客様に紹介されています。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!