SpringBoot Admin的基本使用(单体应用)

  • springboot项目和springboot admin项目不建议放在一起,因为目的是为了监控,如果放在一起的话,一旦springboot挂了,springboot admin也就一起挂了,监控就失去意义.
  • 搭建监控项目:
    <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-server</artifactId>
                <version>2.4.1</version>
            </dependency>
    

    注意版本号要springboot版本号一致.

    @SpringBootApplication
    @EnableAdminServer
    public class MindsaApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(MindsaApplication.class, args);
        }
    
    }

    启动类上加注解EnableAdminServer

    server:
      port: 8000
    

    配置端口8000

  • 配置要监控的服务

    <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-client</artifactId>
                <version>2.4.1</version>
            </dependency>

    版本号要一致

    spring:
      application:
        name: jingxihua-inner # 服务名称
      boot:
        admin:
          client:
            url: http://localhost:8000 #监控中心地址
            instance:
              prefer-ip: true #以IP的形式展示服务列表
               # 如果配置了server.servlet.context-path,则改地址也要加上
              service-url: http://localhost:8088 #监控服务地址(当前服务的地址)
    server:
      port: 8088
    management:
      endpoints:
        web:
          exposure:
            include: "*"
      endpoint:
        health:
          show-details: always
    logging:
      file:
        name: jingxihua-inner.log
    

     

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文子阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值