Spring 普通 JSON 中的数据 REST(非 HAL 格式)
Spring Data REST in plain JSON (not HAL format)
如何将 Spring Data Rest 配置为 return plain JSON 而不是 HAL(JSON 带有类似超媒体的链接)
相关
- Spring Data Rest -Disable self links(HAL) in Json
- 又大Disable Hypertext Application Language (HAL) in JSON?
- 使用jsonapi instead of HAL Changing the JSON format for spring-data-rest
将以下 属性 添加到您的 application.properties 或 yml 中。默认为 application/hal+json
spring.data.rest.defaultMediaType=application/json
对我来说spring.data.rest.defaultMediaType=application/json
不生效。但它可以通过编程配置来接近,如下所示:
public class SpringRestConfiguration implements RepositoryRestConfigurer {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setDefaultMediaType(MediaType.APPLICATION_JSON);
config.useHalAsDefaultJsonMediaType(false);
}
}
如何将 Spring Data Rest 配置为 return plain JSON 而不是 HAL(JSON 带有类似超媒体的链接)
相关
- Spring Data Rest -Disable self links(HAL) in Json
- 又大Disable Hypertext Application Language (HAL) in JSON?
- 使用jsonapi instead of HAL Changing the JSON format for spring-data-rest
将以下 属性 添加到您的 application.properties 或 yml 中。默认为 application/hal+json
spring.data.rest.defaultMediaType=application/json
对我来说spring.data.rest.defaultMediaType=application/json
不生效。但它可以通过编程配置来接近,如下所示:
public class SpringRestConfiguration implements RepositoryRestConfigurer {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setDefaultMediaType(MediaType.APPLICATION_JSON);
config.useHalAsDefaultJsonMediaType(false);
}
}