Integrate spring-boot-admin (2) Build admin-client

1. Add the following dependencies to the spring boot application that needs to be accessed

<!-- 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. Add admin-server configuration in application.yml

# 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. Start the application

After successful registration, there will be an id
insert image description here

4. Log in to admin to see the application

insert image description here
insert image description here
insert image description here

5. Precautions

If the client is a security-authenticated application, it needs to pass /actuatorand /instancesrelease, otherwise it will fail to register, add it to the security configuration file

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

Guess you like

Origin blog.csdn.net/q283614346/article/details/121146871