第 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

Expand
教程链接描述

Spring Boot 和 Spring Cache 远程模式

演示如何将 Spring Caches 与 Spring Boot 和 Data Grid Server 搭配使用。

Spring Boot、Spring Cache、Reactor 和 Infinispan Server

演示如何将 Spring Caches 与 Spring Boot Reactor 和 Data Grid Server 搭配使用。

Spring Boot 和 Spring Session 远程模式

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

Spring Boot 和 Spring Cache 嵌入式模式

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

Spring Boot 和 Spring Session 嵌入式模式

演示如何将 Spring Session 与 Spring Boot 和 Data Grid Embedded 一起使用。

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

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

Data Grid 文档

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

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部