Skip to content

Commit e3dfab0

Browse files
author
YunaiV
committed
增加 actuate 示例
1 parent ff43301 commit e3dfab0

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package cn.iocoder.springboot.lab34.actuatordemo.config;
22

33
import org.springframework.boot.actuate.info.InfoContributor;
4+
import org.springframework.boot.actuate.info.MapInfoContributor;
45
import org.springframework.boot.actuate.info.SimpleInfoContributor;
56
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
68

79
import java.util.Collections;
810

9-
//@Configuration
11+
@Configuration
1012
public class ActuateConfig {
1113

1214
@Bean
@@ -15,4 +17,9 @@ public InfoContributor exampleInfo() {
1517
Collections.singletonMap("key", "value"));
1618
}
1719

20+
@Bean
21+
public InfoContributor exampleInfo02() {
22+
return new MapInfoContributor(Collections.singletonMap("example02", "nicai"));
23+
}
24+
1825
}

lab-34/lab-34-actuator-demo-info/src/main/java/cn/iocoder/springboot/lab34/actuatordemo/demo/DemoInfoContributor.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import org.springframework.boot.actuate.info.Info;
44
import org.springframework.boot.actuate.info.InfoContributor;
5+
import org.springframework.stereotype.Component;
56

67
import java.util.Collections;
78

8-
//@Component
9+
@Component
910
public class DemoInfoContributor implements InfoContributor {
1011

1112
@Override

lab-34/lab-34-actuator-demo-info/src/main/resources/META-INF/build-info.properties

-1
This file was deleted.

lab-34/lab-34-actuator-demo-info/src/main/resources/application.yaml

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ management:
44
info:
55
enabled: true # 是否开启。默认为 true 开启。
66
info:
7-
#
8-
git:
7+
# EnvironmentInfoContributor 的配置项
8+
env:
99
enabled: true
10-
mode: full
10+
# BuildInfoContributor 的配置属性
1111
build:
1212
enabled: true
13-
env:
13+
# GitInfoContributor 的配置属性
14+
git:
1415
enabled: true
16+
mode: SIMPLE # Git 信息展示模式。SIMPLE 默认,只展示精简的 Git 版本信息;FULL 模式,展示完整的 Git 版本信息。
1517

1618
endpoints:
1719
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
@@ -20,12 +22,12 @@ management:
2022
exposure:
2123
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
2224
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
23-
#
25+
26+
# info 配置项
2427
info:
2528
app:
2629
java:
2730
source: @java.version@
2831
target: @java.version@
2932
encoding: UTF-8
3033
version: @project.version@
31-

lab-34/lab-34-actuator-demo-info/target/classes/application.yaml

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ management:
44
info:
55
enabled: true # 是否开启。默认为 true 开启。
66
info:
7-
#
8-
git:
7+
# EnvironmentInfoContributor 的配置项
8+
env:
99
enabled: true
10-
mode: full
10+
# BuildInfoContributor 的配置属性
1111
build:
1212
enabled: true
13-
env:
13+
# GitInfoContributor 的配置属性
14+
git:
1415
enabled: true
16+
mode: SIMPLE # Git 信息展示模式。SIMPLE 默认,只展示精简的 Git 版本信息;FULL 模式,展示完整的 Git 版本信息。
1517

1618
endpoints:
1719
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
@@ -20,12 +22,12 @@ management:
2022
exposure:
2123
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
2224
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。
23-
#
25+
26+
# info 配置项
2427
info:
2528
app:
2629
java:
2730
source: 1.8.0_144
2831
target: 1.8.0_144
2932
encoding: UTF-8
3033
version: 2.2.2.RELEASE
31-

0 commit comments

Comments
 (0)