How exactly should Spring Data Rest be configured to return plain JSON instead of HAL (JSON with Hypermedia like links)
Related
Add the below property to your application.properties or yml . By default it is application/hal+json
spring.data.rest.defaultMediaType=application/json
for me spring.data.rest.defaultMediaType=application/json
does not take effect. But it can be approched by programmed config, like below :
public class SpringRestConfiguration implements RepositoryRestConfigurer {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setDefaultMediaType(MediaType.APPLICATION_JSON);
config.useHalAsDefaultJsonMediaType(false);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.