Skip to content

Commit

Permalink
增加 actuate 示例
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Dec 20, 2019
1 parent 0ced79c commit 1fb9143
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ management:
show-details: ALWAYS # 何时显示完整的健康信息。默认为 NEVER 都不展示。可选 WHEN_AUTHORIZED 当经过授权的用户;可选 ALWAYS 总是展示。
status:
http-mapping: # 设置不同健康状态对应的响应状态码
DOWN: 403
DOWN: 503
order: DOWN, OUT_OF_SERVICE, UP, UNKNOWN # 状态排序。
health:
# DiskSpaceHealthIndicator 配置项,对应 DiskSpaceHealthIndicatorProperties
Expand Down
57 changes: 57 additions & 0 deletions lab-34/lab-34-actuator-demo-info/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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-acturator-demo-info</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>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</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,28 @@
management:
endpoint:
info:
enabled: true
info:
git:
enabled: true
mode: simple

endpoints:
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。

info:
app:
java:
source: 1.8
target: 1.8
encoding: UTF-8
build:
java:
source: @java.version@
target: @java.version@
version: @project.version@
28 changes: 28 additions & 0 deletions lab-34/lab-34-actuator-demo-info/target/classes/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
management:
endpoint:
info:
enabled: true
info:
git:
enabled: true
mode: simple

endpoints:
# Actuator HTTP 配置项,对应 WebEndpointProperties 配置类
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
exclude: # 在 include 的基础上,需要排除的端点。通过设置 * ,可以排除所有端点。

info:
app:
java:
source: 1.8
target: 1.8
encoding: UTF-8
build:
java:
source: 1.8.0_144
target: 1.8.0_144
version: 2.2.2.RELEASE
1 change: 1 addition & 0 deletions lab-34/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<modules>
<module>lab-34-actuator-demo</module>
<module>lab-34-actuator-demo-health</module>
<module>lab-34-actuator-demo-info</module>
</modules>


Expand Down

0 comments on commit 1fb9143

Please sign in to comment.