集成spring-boot-admin(二)搭建admin-client

1、在需要接入的spring boot应用上加入以下依赖

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

<!-- spring-boot-actuator(必须) -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- 在管理界面中与JMX-beans进行交互所需要被依赖的JAR -->
<dependency>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-core</artifactId>
    <version>1.7.1</version>
</dependency>

2、在application.yml增加admin-server配置

# admin-server配置
spring:
  application:
    # 在spring-boot-admin 上的的显示名称
    name: cherry-devops
  boot:
    admin:
      client:
        # admin-server地址
        url: http://localhost:8000
        # admin-server security用户名
        username: admin
        # admin-server security密码
        password: 123456
# 开放健康检查接口
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

3、启动应用

注册成功会有个id
在这里插入图片描述

4、登录admin可以看到该应用

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5、注意事项

如果客户端是security鉴权的应用,需要把/actuator/instances放行,不然会注册失败,在security的配置文件加上

.antMatchers("/actuator/**", "/instances/**").permitAll()

猜你喜欢

转载自blog.csdn.net/q283614346/article/details/121146871
今日推荐