0
点赞
收藏
分享

微信扫一扫

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目_spring

🍁 作者:知识浅谈,CSDN签约讲师,CSDN博客专家,华为云云享专家,阿里云星级博主
📌 擅长领域:全栈工程师、爬虫、ACM算法
💒 公众号:知识浅谈

🤞部署SpringAdmin监控springboot项目总结🤞

​坑点:注意SpringAdmin版本号和监控的项目中Springboot版本保持一致。​

🎈SpringAdmin原理介绍

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目_新建项目_02


SpringAdmin监控使用的是CF的模式,就是监控端需要单独搭建一个SpringAdminServer服务器,SpringAdminCient要在监控的Springboot项目中引入。

🎈SpringAdminServer开发

🎐第一步:新建项目,增加依赖spring-boot-admin-starter-server
​对应的springboot版本为2.7.2​

<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

🎐第二步:配置文件设置

server: #设置server端口号为9000
port: 9000

🎐第三步:启动类上添加注解

@EnableAdminServer //加上这个注解,才对外界提供adminserver的服务。
@SpringBootApplication
public class EsDemoApplication {

public static void main(String[] args) {
SpringApplication.run(EsDemoApplication.class, args);
}
}

🎐第四步:查看结果

​http://localhost:9000/​

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目_新建项目_03

🎈SpringAdminClient开发

🎐第一步:新建项目,增加依赖spring-boot-admin-starter-server
​对应的springboot版本为2.7.2​

<!---->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

🎐第二步:配置文件设置

spring:
boot:
admin:
client:
url: http://localhost:9000
instance:
prefer-ip: true #基于ip地址向服务器注册,默认域名注册

management:
endpoints:
web:
exposure:
include: '*'
enabled-by-default: true #开启所有监控端点
endpoint:
health:
show-details: always
enabled: true
info:
enabled: true
metrics:
enabled: true

🎐第三步:查看结果

​http://localhost:9000/​

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目_新建项目_04


进入详细的实例中

粗暴项目监控,快速上手 Spring 家族的亲儿子 SpringAdmin 监控项目_新建项目_05

🍚总结

以上就从头到尾进行了实现,有需要的可以借鉴一下,希望对你有所帮助。

举报

相关推荐

0 条评论