Set up eureka,gateway,admin,redis,docker series of admins

spring cloud admin

brief introduction

Spring Boot Admin is used to monitor applications based on Spring Boot. It provides a simple visual WEB UI based on Spring Boot activator. Spring Boot Admin provides many functions, such as displaying name, id and version, displaying online status, Loggers' log level management, Threads thread management, Environment management, etc.

Create an empty module project

Add pom dependency

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>

            </exclusions>
        </dependency>

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-core -->
        <dependency>
            <groupId>org.jolokia</groupId>
            <artifactId>jolokia-core</artifactId>
            <version>1.6.2</version>
        </dependency> 
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Create a startup class

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

configuration file

spring:
  application:
    name: spring-boot-admin
  profiles:
    active:
      - secure
server:
  port: 8788

# tag::configuration-eureka[]
eureka:   #<1>
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
  client:
    registryFetchIntervalSeconds: 5
    serviceUrl:
      defaultZone: ${EUREKA_SERVICE_URL:http://127.0.0.1:8761}/eureka/


management:
  endpoints:
    web:
      exposure:
        include: "*"  #<2>
  endpoint:
    health:
      show-details: ALWAYS
# end::configuration-eureka[]

---
spring:
  profiles: insecure

---
spring:
  profiles: secure
  security:
    user:
      name: "Login user name"
      password: "Login password"
eureka:
  instance:
    metadata-map:
      user.name: "User name"         #These two are needed so that the server
      user.password: "Password" #can access the protected client endpoints

Register yourself with the registry

 

Open local localhost: 8788 and you will see admin. I have two api projects here, one is gateway and the other is admin

In the next chapter, I will start to work on the Redisapi project

Tags: Java Spring log4j Maven

Posted on Thu, 26 Mar 2020 10:41:00 -0400 by malam