我正在开发一个使用spring-boot和spring-Hateoas的rest应用程序。我写的DTO是:
Bill.java
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("bills")
public class Bill{
依赖关系:
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:
@Configuration
@Import(BillServiceConfig.class)
@EnableAutoConfiguration
@EnableEurekaClient
@ComponentScan({"com.billing"})
@EnableWebMvc
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
public class Application {
BillController.java:
@RequestMapping(method = RequestMethod.GET, value = "")
public ResponseEntity<Resources<Resource<Bill>>> getBills(@PathVariable String billUid)
我使用的spring-boot版本是1.2.2。我得到的输出是
`_embedded: {
BillList:
{`
这里的json Root名称是BillList。但我需要它作为“账单”而不是"BillList“。在这个问题上,有人能帮上忙吗?提前谢谢。
发布于 2015-04-28 16:11:02
_embedded
子句中的键实际上是关系名称。因此,它们是通过Spring HATEOAS中的RelProvider
抽象获得的。定制它们的最简单方法是使用@Relation
注释域类型,并为项和集合关系定义您所期望的关系名称。
获取_embedded
子句中使用的正确复数的一种简单方法是将Evo Inflector JAR作为文档化的here添加到类路径中。
https://stackoverflow.com/questions/29394061
复制相似问题