今天嘗試項目裏面加入Spring Boot Admin,它是一個Web應用程序,用於管理和監視Spring Boot應用程序。它分爲Server端和Client端,每個應用程序都被視爲客戶端並註冊到管理服務器。實現的原理則是基於Spring Boot Actuator提供的端點。
搭建admin-server
1.pom文件引入相關依賴
<!-- 添加admin-server、admin-server-ui依賴 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.0.1</version>
</dependency>
2.啓動類添加註解@EnableAdminServer
3.啓動服務出現下面錯誤信息
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method reactor.retry.Retry.retryMax(I)Lreactor/retry/Retry; but it does not exist. Its class, reactor.retry.Retry, is available from the following locations:
jar:file:/D:/mymaven/repository/io/projectreactor/addons/reactor-extra/3.2.0.RELEASE/reactor-extra-3.2.0.RELEASE.jar!/reactor/retry/Retry.class
It was loaded from the following location:
file:/D:/mymaven/repository/io/projectreactor/addons/reactor-extra/3.2.0.RELEASE/reactor-extra-3.2.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of reactor.retry.Retry
項目沒能啓動就報錯,查看錯誤信息。大概意思:“嘗試調用方法reator . retry.retry.retrymax (I)Lreactor/retry/ retry;但它並不存在。它的類,reactor.retry。重試,可在以下地點下載:下面就是兩個下載地址”。上網查找相關報錯信息發現根本原因就是pom.xml文件中版本依賴有問題。查看我spring boot版本信息:2.1.0.RELEASE,於是將spring-boot-admin-server也升級版本
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.0</version>
</dependency>
再次啓動成功,特此記錄!