第 3 章 Spring 和 Spring Boot


3.1. Spring 和 Spring Boot 指南

注意

这些代码教程使用 Data Grid 服务器,并且至少需要一个正在运行的实例。

运行 Spring 示例

$ mvn -s /path/to/maven-settings.xml package exec:exec
Copy to Clipboard Toggle word wrap

运行 Spring Boot 示例

$ mvn -s /path/to/maven-settings.xml spring-boot:run
Copy to Clipboard Toggle word wrap

显示激活器统计

导航到浏览器中的 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
Copy to Clipboard Toggle word wrap

Expand
教程链接描述

Spring Boot 和 Spring Cache 远程模式

演示了如何在 Spring Boot 和 Data Grid Server 中使用 Spring Caches。

Spring Boot 和 Spring Session 远程模式

演示了如何在 Spring Boot 和 Data Grid Server 中使用 Spring Session。

Spring Boot 和 Spring Cache 嵌入式模式

演示了如何在 Spring Boot 和 Data Grid Embedded 中使用 Spring Caches。

Spring Boot 和 Spring Session 嵌入式模式

演示了如何在 Spring Boot 和 Data Grid Embeded 中使用 Spring Session。

在没有 Spring Boot 的情况下嵌入 Spring 缓存

演示了如何在没有 Spring Boot 的情况下使用 Spring Cache 和 Data Grid Embeded。

在没有 Spring Boot 的情况下嵌入 Spring 会话

演示了如何在没有 Spring Boot 的情况下使用 Spring Session 和 Data Grid Embeded。

Data Grid 文档

您可以在以下文档中找到更多资源:

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat