实现springboot的admin管理监控案例

实现springboot的admin管理监控案例

package com.itheima.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
     
    @RequestMapping("/user/findAll")
    public void sayHello() {
     
        System.out.println("hello");
    }
}

application中的配置

# 暴露所有的监控点
management.endpoints.web.exposure.include=*
# 开启endpoint 关闭服务功能
management.endpoint.shutdown.enabled=true

# springboot admin 服务端的地址,http://localhost:9000
# 连接到springboot的admin
spring.boot.admin.client.url=http://localhost:9000

admin-server中的配置

server.port=9000

启动引导类

package com.itheima;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAdminServer //开启springboot的admin的服务端的支持
public class Springboot06AdminServerApplication {
     

    public static void main(String[] args) {
     
        SpringApplication.run(Springboot06AdminServerApplication.class, args);
    }

}

pom文件中的配置

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.itheima</groupId>
    <artifactId>springboot06-admin-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot06-admin-server</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-boot-admin.version>2.1.5</spring-boot-admin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
        </dependency>


    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-dependencies</artifactId>
                <version>${
     spring-boot-admin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


</project>

你可能感兴趣的:(实现springboot的admin管理监控案例)