🍁 作者:知识浅谈,CSDN 签约讲师,CSDN 博客专家,华为云云享专家,阿里云星级博主
📌 擅长领域:全栈工程师、爬虫、ACM 算法
💒 公众号:知识浅谈
🔥 联系方式 vx:zsqtcc
🤞部署 SpringAdmin 监控 springboot 项目总结🤞
坑点:注意SpringAdmin版本号和监控的项目中Springboot版本保持一致。
🎈SpringAdmin 原理介绍
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的服务。@SpringBootApplicationpublic class EsDemoApplication {
public static void main(String[] args) { SpringApplication.run(EsDemoApplication.class, args); }}
复制代码
🎐第四步:查看结果http://localhost:9000/
🎈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/
进入详细的实例中
🍚总结
以上就从头到尾进行了实现,有需要的可以借鉴一下,希望对你有所帮助。
评论