第 3 章 Spring 和 Spring Boot
3.1. Spring 和 Spring Boot 指南 复制链接链接已复制到粘贴板!
这些代码教程使用 Data Grid Server 并至少需要一个正在运行的实例。
运行 Spring 示例
可以在没有 Spring Boot 的情况下使用 Spring 运行两个简单的教程:
- 测试缓存
$ ./mvnw -s /path/to/maven-settings.xml package exec:exec@spring-caching
- 测试注解
$ ./mvnw -s /path/to/maven-settings.xml package exec:exec@spring-annotations
要运行 Spring Boot 指南,请使用以下命令:
$ ./mvnw -s /path/to/maven-settings.xml spring-boot:run
显示操作器统计信息
在浏览器中导航到 http://localhost:8080/actuator/metrics 以显示可用指标列表。缓存指标以 "cache"作为前缀。使用标签显示每个缓存的每个指标。例如,对于 basque-names 缓存中的"puts"统计:
http://localhost:8080/actuator/metrics/cache.puts?tag=name:basque-names
使用 Prometheus 收集统计信息
此项目中的 prometheus.yml 文件包含 host.docker.internal 绑定,它允许 Prometheus 访问 Spring actuator 公开的指标。
将以下命令中的 YOUR_PATH 值改为运行 Prometheus 的目录,然后运行:
Podman
$ podman run -d --name=prometheus -p 9090:9090 -v YOUR_PATH/integrations/spring-boot/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
| 教程链接 | 描述 |
|---|---|
| 演示如何将 Spring Caches 与 Spring Boot 和 Data Grid Server 搭配使用。 | |
| 演示如何将 Spring Caches 与 Spring Boot Reactor 和 Data Grid Server 搭配使用。 | |
| 演示如何在 Spring Boot 和 Data Grid Server 中使用 Spring Session。 | |
| 演示如何在 Spring Boot 和 Data Grid Embedded 中使用 Spring Cache。 | |
| 演示如何将 Spring Session 与 Spring Boot 和 Data Grid Embedded 一起使用。 | |
| 演示如何在没有 Spring Boot 的情况下使用 Spring Cache 和 Data Grid Embedded。 |
Data Grid 文档
您可以在以下文档中找到更多资源: