# 8.7. Spring HATEOAS

如果您开发使用超媒体的 RESTful API，Spring Boot 会为 Spring HATEOAS 提供自动配置，该配置适用于大多数应用程序。自动配置取代了使用 `@EnableHypermediaSupport` 的需要，并注册了许多 bean 来简化构建基于超媒体的应用程序，包括 LinkDiscoverers（用于客户端支持）和配置为正确将响应编组到所需表示的 `ObjectMapper`。 `ObjectMapper`是通过设置各种 `spring.jackson.*` 属性来定制的，或者如果存在的话，可以通过`Jackson2ObjectMapperBuilder` bean 来定制。

您可以使用 `@EnableHypermediaSupport`来控制 Spring HATEOAS 的配置。请注意，这样做会禁用前面描述的 ObjectMapper 自定义。

`spring-boot-starter-hateoas` 特定于 Spring MVC，不应与 Spring WebFlux 结合使用。为了将 Spring HATEOAS 与 Spring WebFlux 一起使用，您可以添加对 `org.springframework.hateoas:spring-hateoas` 的直接依赖项以及 `spring-boot-starter-webflux`。

默认情况下，接受 `application/json` 的请求将收到`application/hal+json`响应。要禁用此行为，请将`spring.hateoas.use-hal-as-default-json-media-type` 设置为 false 并定义`HypermediaMappingInformation`或 `HalConfiguration`来配置 Spring HATEOAS 以满足应用程序及其客户端的需求。

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.shiker.tech/spring-boot-can-kao-wen-dang/8.-wang-luo/8.7.-spring-hateoas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
