Я предлагаю вам использовать класс контроллера, как показано ниже.
@RestController
@RequestMapping(value = "${spring.data.rest.base-path}/parent")
public class Parent {
@GetMapping
public ResponseEntity<Map> parentNode(HttpServletRequest request) {
Map<String,String> parth=new HashMap<>();
parth.put("child-one", request.getRequestURL()+"/child-one");
parth.put("child-two", request.getRequestURL()+"/child-two");
parth.put("child-three", request.getRequestURL()+"/child-three");
parth.put("child-four", request.getRequestURL()+"/child-four");
return ResponseEntity.ok(parth);
}
@RequestMapping(value = { "/child-one" }, method = RequestMethod.GET)
public ResponseEntity<String> childOne() {
return ResponseEntity.ok("child-one");
}
@RequestMapping(value = { "/child-two" }, method = RequestMethod.GET)
public ResponseEntity<String> childTwo() {
return ResponseEntity.ok("child-two");
}
@RequestMapping(value = { "/child-three" }, method = RequestMethod.GET)
public ResponseEntity<String> childThree() {
return ResponseEntity.ok("child-three");
}
@RequestMapping(value = { "/child-four" }, method = RequestMethod.GET)
public ResponseEntity<String> childFour() {
return ResponseEntity.ok("child-four");
}
}
Spring-boot application.yml, показанный ниже
server:
port: 8089
spring:
data:
rest:
base-path: /api/
результат, как показано ниже
![enter image description here](https://i.stack.imgur.com/UUEre.png)