1。スプリングブート管理者の紹介
スプリングブート管理githubオープンソースアドレス:https://github.com/codecentric/spring-boot-admin
その主な機能は、Spring Boot Actuatorに基づいたシンプルなWeb UIディスプレイを提供することです。
2。プロジェクトの使用:
1. Maven Webプロジェクトを作成します
2。POM依存関係の構成
<Dependency> groupId> org.springframework.boot </groupid> <artifactid> spring-boot-starter-web </artifactid> </dependency> <dependency> groupid> org.springframework.boot </groupid> <artifactid> spring-boot-startertertertertertertertertertid </artifactid </artifactid> <GroupId> de.CodeCentric </groupId> <artifactid> spring-boot-admin-starter-client </artifactid> </dependency> <dependency> de.codecentric </groupid> <artifactid> spring-boot-admin-server </artifactid> depenty> </depenty> </depenty <Artifactid> spring-boot-admin-server-ui </artifactid> </dependency> <seplency> <groupid> de.codecentric </groupid> <artifactid> spring-boot-admin-ui-login </artifactid> </dependency>
上記の構成をpom.xmlに追加します
管理サーバー:Spring-Boot-Admin-Server、Spring-Boot-Admin-Server-UI
管理者クライアント:Spring-Boot-Admin-Starter-Client(さらに、このアイテムはサーバー自体の動作ステータスを監視できます。他のプロジェクトは、監視を導入するためにクライアントを導入するだけです)
セキュリティ:Spring-Boot-Starter-Security
ログイン検証:Spring-Boot-Admin-Server-Ui-Login(自分で簡単なログインインターフェイスを追加することもできます)
3。application.yml
情報:app:name:inpedバージョン:V1.0.0 [HTML]プレーンコピログを表示:ファイル: "d:/logs/imard/boot.log" management:context-path: "/actuator" spring:application: "@pom.artifactid@" boot:boot:admin:url:http://www.test.com:active:80 prepileプロファイル:セキュリティ管理:セキュリティ:有効:falseセキュリティ:基本:false ---スプリング:スプリング:プロファイル:secure boot:admin:username: "$ {security.user.name}"パスワード: "$ {security.user.password}"セキュリティ:ユーザー:名前:ユーザーパスワード:合格その中には、spring.boot.admin.urlが管理者サーバーアドレスを宣言します(他のプロジェクトはこのURLを介して管理監視に積極的に登録します)
情報構成アプリに関する基本情報
ネイティブホストのwww.test.comマッピング
4。application.java
@configuration @enableautoconfiguration @enableadminserver public classアプリケーションSpringbootservletinitializer {@Override Protected SpringApplicationBuilder Configure(SpringApplicationBuilder Application){return application.sources(application.class); } public static void main(string [] args){springApplication.run(application.class、args); }}@enableadminserverこの注釈を追加して監視を開始します
5。SecurityConfig
@profile( "secure")@configuration public class securityconfig extends websecurityconfigureradapter {@override保護されたvoid configure(httpsecurity http)スロー例外{http.formlogin()。logpage( "/login.html")。 http.logout()。logouturl( "/logout"); http.csrf()。disable(); http.authorizerequests().antmatchers( "/login.html"、 "/**/*.css"、 "/img/**"、 "/third-party/**")。 http.authorizerequests()。antmatchers( "/api/**")。pimitall()。antmatchers( "/**").authenticated(); // http.httpbasic(); }}Spring Securityを使用して基本的なセキュリティポリシーを構成します
6。監督と管理
1〜5ステップが設定されたら、アプリケーションを使用して監視プログラムを開始します。
下の図に示すように、http://www.test.com:8080/login.html監視ログインインターフェイスを介したセキュリティ検証後:
詳細を入力して、特定のプロジェクト監視情報(詳細、ログ、メトリック、環境、ロギング、JMX、スレッド、監査、トレース、heapdump)を表示します。
要約します
上記は、紹介されたSpring Bootで管理者監視を追加する方法です。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!