Dashboard監控頁面
dashboard監控功能:我們需要前端頁面能夠監控提供者provider8001的工作狀態
對dashboard監控頁面的介紹:
1.在使用者端導依賴
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.example</groupId> <artifactId>springcloud</artifactId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.lian</groupId> <artifactId>springcloud-consumer-hystrix-dashboard</artifactId> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.example</groupId> <artifactId>springcloud-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> <version>2.1.2.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix-dashboard --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> <version>2.1.3.RELEASE</version> </dependency> </dependencies> </project>
2.組態檔
3.主啟動類開啟支援註解
4.在provider8001也要確儲存在它能被監控的依賴actuator
5.在provider8001要增加一個可以供前端存取的servlet,同時入到springboot容器中
6.測試
可以先存取8001埠下面的方法看看能不能調到底層資料,可以再
存取:http://localhost:9001/hystrix 出現下面頁面
我們每重新整理一次,監控頁面就有更新
Zuul路由閘道器
目的:為了安全,將前端url存取時真實的ip替換成其他
zuul的使用要注入到eureka中,需要有組態檔,組態檔被spring boot託管
1.導包
<dependencies> <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-zuul --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
2.組態檔
3.主啟動類
4.測試