我有一篇Spring Boot服务文章。我正在使用Spring Data Rest和MongoDB。我在自定义控制器中覆盖findAll()方法。但是在响应中,我缺少_links和页面详细信息。我正在寻找一种在自定义控制器中重写findAll()方法时获取_链接和页面信息的方法。
预期的响应:
"_links": {
"self": {
"href": "http://localhost:8080/article"
},
"profile": {
"href": "http://localhost:8080/profile/articles"
},
"search": {
"href": "http://localhost:8080/articles/search"
},
"page": {
"size": 20,
"totalElements": 61,
"totalPages": 5,
"number": 0
}
}
}
我有一篇Spring Boot服务文章。我正在使用Spring Data Rest和MongoDB。我在自定义控制器中覆盖findAll()方法。但是在响应中,我缺少_links和页面详细信息。我是...
在pom.xml中添加以下依赖项或在build.gradle中添加相关的gradle依赖项>>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>