Getting ready

To help us visualize the metrics better, we will use a great open source project, spring-boot-admin, located at https://github.com/codecentric/spring-boot-admin. It provides a simple web UI on top of the Spring Boot Actuators to give a nicer view of the various data.

We will create a simple admin application in Gradle using the instructions from https://github.com/codecentric/spring-boot-admin#server-application by performing the following simple steps:

  1. Go to start.spring.io and create a new application template with the following fields:
  • Generate a: Gradle Project
  • With: Java
  • Spring Boot: 2.0.0 (SNAPSHOT)
  • Group: org.sample.admin
  • Artifact: spring-boot-admin-web
  • Name: Spring Boot Admin Web
  • Description: Spring Boot Admin Web Application
  • Package Name: org.sample.admin
  • Packaging: Jar
  • Java Version: 8
  1. Select the Actuator option under Search for dependencies
  2. Click on Generate Project alt + to download the application template archive
  3. Extract the contents from the directory of your choice
  4. In the extracted directory, execute the gradle wrapper command line to generate a gradlew script
  5. In the build.gradle file, add the following dependencies to the dependencies block:
compile("de.codecentric:spring-boot-admin-server:2.0.0-SNAPSHOT") 
compile("de.codecentric:spring-boot-admin-server-ui:2.0.0-SNAPSHOT ") 
  1. We also need to update the repositories block with a reference to use the snapshots repository (as the time of writing, the SBA is not yet released):
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 
  1. Open the SpringBootAdminWebApplication.java file located in the src/main/java/spring-boot-admin-web directory and add the following annotations to the SpringBootAdminWebApplication class:
@SpringBootApplication 
@EnableAdminServer 
public class SpringBootAdminWebApplication { 
 
  public static void main(String[] args) { 
    SpringApplication.run( 
                      SpringBootAdminWebApplication.class, 
args); } }
  1. Open the application.properties file located in the src/main/resources directory and add the following settings:
server.port: 8090 
spring.application.name: Spring Boot Admin Web 
spring.cloud.config.enabled: false 
spring.jackson.serialization.indent_output: true
  1. We are now ready to start our Admin Web Console by running ./gradlew bootRun and open the browser to http://localhost:8090 to see the following output:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.197.49