这是我参与8月更文挑战的第5天,活动详情查看:8月更文挑战
有些地方描述为四大组件,有些地方描述为四大核心原理,有些地方描述为四大神器。我的认为称呼神器更为合适。如今描述Actuator监控管理、Spring Boot CLI 命令行工具。java
Actuator 是 Spring Boot 的一个很是强大的功能。它能够实现应用程序的监控管理,好比帮助咱们收集应用程序的运行状况、监测应用程序的健康情况以及显示HTTP跟踪请求信息等。它是咱们搭建微服务架构必不可少的环节,是整个系统稳定运行的保障。web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
Actuator 内置有不少端点(endpoint),咱们经过这些端点能够得到不一样的监控信息。但Actautor默认只开启health和info两个端点,须要对application.yml文件进行配置:spring
management:
endpoints:
web:
exposure:
include: '*'
复制代码
其中'*'
标识开启全部端点。
也能够开启指定端点:json
management:
endpoints:
web:
exposure:
include: health,info,httptrace
复制代码
上述配置表示开启health、info、httptrace端点。此时启动程序访问http://localhost:8080/actuator/health ,会看到以下结果。springboot
{"status":"UP"}
复制代码
UP说明当前系统正常运行。markdown
Spring Boot CLI(Command Line Interface)是一款用于快速搭建基于Spring原型的命令行工具。它支持运行Groovy脚本,这意味着你能够拥有一个与Java语言相似的没有太多样板代码的语法。经过CLI来使用Spring Boot不是惟一方式,但它是让Spring应用程序搭建的最快速方式。架构
下载地址
repo.spring.io/release/org…
配置环境变量app
若是对Groovy不熟悉,能够直接编写java的Controller。spring-boot
@RestController
public class AdviceController {
@RequestMapping("/")
public String hello(){
return "hello world!"
}
}
复制代码