首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >@jsonRootName不支持spring boot starter hateoas

@jsonRootName不支持spring boot starter hateoas
EN

Stack Overflow用户
提问于 2015-04-01 22:53:05
回答 1查看 1.5K关注 0票数 2

我正在开发一个使用spring-boot和spring-Hateoas的rest应用程序。我写的DTO是:

Bill.java

代码语言:javascript
运行
复制
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("bills")
public class Bill{

依赖关系:

代码语言:javascript
运行
复制
dependencies {
compile "org.springframework.boot:spring-boot-starter-hateoas"
compile "org.springframework.boot:spring-boot-starter-ws"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.cloud:spring-cloud-starter-eureka:${springCloudVersion}"

testCompile("org.springframework.boot:spring-boot-starter-test")
}

Application.java:

代码语言:javascript
运行
复制
@Configuration
@Import(BillServiceConfig.class)
@EnableAutoConfiguration
@EnableEurekaClient
@ComponentScan({"com.billing"})
@EnableWebMvc
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
public class Application {

BillController.java:

代码语言:javascript
运行
复制
 @RequestMapping(method = RequestMethod.GET, value = "")
 public ResponseEntity<Resources<Resource<Bill>>> getBills(@PathVariable String billUid)

我使用的spring-boot版本是1.2.2。我得到的输出是

代码语言:javascript
运行
复制
`_embedded: {
BillList:
{`

这里的json Root名称是BillList。但我需要它作为“账单”而不是"BillList“。在这个问题上,有人能帮上忙吗?提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-04-28 16:11:02

_embedded子句中的键实际上是关系名称。因此,它们是通过Spring HATEOAS中的RelProvider抽象获得的。定制它们的最简单方法是使用@Relation注释域类型,并为项和集合关系定义您所期望的关系名称。

获取_embedded子句中使用的正确复数的一种简单方法是将Evo Inflector JAR作为文档化的here添加到类路径中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29394061

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档