Skip to content

Commit

Permalink
增加 actuate demo 示例
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Dec 23, 2019
1 parent ca83590 commit ee9a9d1
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lab-34/lab-34-actuator-demo-custom-endpoint/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>lab-34-actuator-demo-custom-endpoint</artifactId>

<dependencies>
<!-- 实现对 Spring MVC 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- 实现对 Actuator 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cn.iocoder.springboot.lab34.actuatordemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cn.iocoder.springboot.lab34.actuatordemo.endpoint;

import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@Endpoint(id = "demo")
public class DemoEndPoint {

@ReadOperation
public Map<String, String> hello() {
Map<String, String> result = new HashMap<>();
result.put("作者", "yudaoyuanma");
result.put("秃头", "true");
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
management:
endpoints:
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
# endpoint:
# shutdown:
# enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
management:
endpoints:
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
# endpoint:
# shutdown:
# enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ management:
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
# endpoint:
# shutdown:
# enabled: true
1 change: 1 addition & 0 deletions lab-34/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<module>lab-34-actuator-demo-metrics</module>
<module>lab-34-actuator-demo-httptrace</module>
<module>lab-34-actuator-demo-auditevents</module>
<module>lab-34-actuator-demo-custom-endpoint</module>
</modules>


Expand Down

0 comments on commit ee9a9d1

Please sign in to comment.