Open In App

Spring Boot – Admin Client

In Sprint Boot, Admin and Client can be implemented so that the client can be registered with the server, and then the server maintains the client’s service health and availability, scales up the service, and also measures the representation of the client.

Spring Boot Admin Server

The Admin Server can represent the UI dashboard of the Spring Boot applications, and it can monitor an application and represent the dashboard metrics of the client server’s health.



Key Terminologies:

Spring Boot Admin Client

Spring Boot Admin Client is a simple spring boot application that includes the spring boot client library and allows the application to register with the spring boot admin server for monitoring and managing the service.

Key Terminologies:



Step-by-Step Implementation of Admin Client in Spring Boot

Step 1: Create the project named GFGSpringClientDemo and add the dependencies and choose tool gradle or maven. We chose Gradle, then created the project and opened it.

Project Structure:

Step 2: Once created the project after that open the application.properities file then configure the admin client and URL and endpoints exposure please refer the code.

spring.boot.admin.client.url=http://localhost:8082
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always

Below we can refer to the main class file:




package in.gfg.demo;
  
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
  
@SpringBootApplication
  
public class GfgSpringClientDemoApplication {
  
    public static void main(String[] args) {
        SpringApplication.run(GfgSpringClientDemoApplication.class, args);
    }
}

The Spring Admin Client configuration is complete and now configure the server and after that run the server and client then open the Spring Admin server dashboard it shows the Spring Admin Client Information.

Step 3: Create another project named GFGSpringAdminDemo and add the dependencies and open it into the Spring STS IDE.

Step 4: Once complete the project creation open the application.properities file and added the below server port configuration code.

server.port: 8083

Project file Structure of GFGSpringAdminDemo:

Step 5: After that open the Spring Boot application main code then the enable annotation into the of the EnableAdminSever. After that save the project and run it and checks if error occurs or not.




package in.gfg.demo;
  
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
  
import de.codecentric.boot.admin.server.config.EnableAdminServer;
  
@SpringBootApplication
@EnableAdminServer
public class GfgSpringAdminDemoApplication {
  
    public static void main(String[] args) {
        SpringApplication.run(GfgSpringAdminDemoApplication.class, args);
    }
}

The Spring Boot Admin Server configuration is also completed here you need to observe one thing can enable the Spring Boot Admin Server on the Spring Boot main method.

Step 6: Both Admin and server configuration is completed after that can be run the spring boot server application and after that run the spring boot admin client application and here that spring admin client can register into the Admin Server and manages and maintain the health of the spring Boot Admin Client.

Output:

In the above picture, we can find out the spring-boot-application it can be shown into the spring boot admin server UI dashboard. It can monitor and manages the spring boot admin client of the spring boot project.

The above picture shows the register information of the spring admin server client application into the spring boot admin server web-based UI dashboard.


Article Tags :