SBAと呼ばれるSpring-Boot-Adminは、Spring-BootのアクチュエータインターフェイスのUI美化とパッケージの監視ツールです。彼は、リスト内のすべての監視されているスプリングブートプロジェクトの基本情報、詳細な健康情報、メモリ情報、JVM情報、ガベージコレクション情報、さまざまな構成情報(データソース、キャッシュリスト、ヒットレートなど)などを参照し、ロガーレベルを直接変更することもできます。
公式ウェブサイト:https://github.com/codecentric/spring-boot-admin
ユーザーガイド:http://codecentric.github.io/spring-boot-admin/1.5.0/
SBAは、いくつかの簡単な手順で構成および使用できます(監視端と監視の端に分割):
監視の終わり:
1.プロジェクトを作成する(省略)
2。依存関係を紹介します:
<Dependency> groupId> de.CodeCentric </groupId> <artifactid> spring-boot-admin-server </artifactid> <version> 1.5.0 </version> </dependency> <redency> <groupid> </依存関係>
3。構成ファイル(Application.yml)構成(オプション):
スプリング:アプリケーション:名前:svc-monitor boot:admin:context-path:/sba#構成アクセスパスはhttp:// localhost:64000/svc-monitor/sbaサーバー:ポート:64000コンテキストパス:/svc-monitor/#unifyアクセスURLがプレフィックスを与えられます。
上記の構成は、特別なアクセスパスを指定することです。これが構成されていない場合、アクセスパスはhttp:// localhost:64000です。
4. @enableadminserverアノテーションを使用して、SBAをアクティブにします。
@SpringBootApplication @ENABLESCHEDULING @ENABLEADMINSERVER PUBLIC CLASS SVCMONITRAPPLICATION {public static void main(string [] args){springApplication.run(svcmonitorApplication.class、args); }}監視対象の端(スプリングブートプロジェクト)は、監視端でそれ自体を登録します。
1.依存関係を追加:
<Dependency> GroupId> de.CodeCentric </groupId> <Artifactid> spring-boot-admin-starter-client </artifactid> <バージョン> 1.5.0 </version> </dependency>
2。構成ファイル(Application.yml)構成:
spring: boot: admin: client: prefer-ip: true # Solve the problem that the host name cannot be recognized during running under Windows url: http://localhost:64000/svc-monitor # Address registered with the server management: port: 64001 security: enabled: false # spring-boot strictly enforce security policies after 1.5.2, so you need to configure this to false info: #Define various additional details to display the app toサーバー:name: "@project.name@"#pom.xmlからの説明: "@project.description@"バージョン: "@project.version@" spring-boot-version: "@project.parent.version@"
3。その他の構成:
プロジェクトバージョン番号を表示する必要がある場合は、pom.xmlにこれ(bubrid-info)を追加する必要があります。
<build> <プラグイン><プラグイン><groupId> org.springframework.boot </groupid> <artifactid> spring-boot-maven-plugin </artifactid> <execution> <execution> <goal> bultinfo </goal> </goal> </execution> execution
4。問題解決:
InetAddress.getLocalHost() throws UnknownHostExceptionエラーが発生することがわかった場合、これはネイティブマシン名とIPの対応が構成されていないためです。
解決:
ホストファイルを編集します。
vi /etc/hosts
IPとマシンの関連付けを追加する名前:192.168.0.31 HOST31 MyHost-31
監視端と監視端の両方が開始された後、http:// localhost:64000/svc-monitor/sbaにアクセスすると、監視対象サービスのさまざまな詳細を確認できます。
上記は、監視された端のアクティブな登録方法です。
別の方法は、監視された端がSpring Cloudを使用してEurekaでサービスを既に登録している場合、監視端はユーラカでこのサービスを直接発見および監視することができます。この方法はデバッグが非常に複雑であるため、ここでは紹介しません。
要約します
上記は、編集者が紹介したスプリングブートサービスを監視するためにスプリングブートアドミンを使用する実装方法です。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!