Upgrade to Spring Boot 2.3 and related changes.

This commit is contained in:
Greg L. Turnquist
2020-10-20 16:24:26 -05:00
parent 1d12ed185c
commit 5f74daf4bd
13 changed files with 44 additions and 35 deletions

View File

@@ -96,13 +96,13 @@ The route for the https://martinfowler.com/bliki/DDD_Aggregate.html[aggregate ro
ResponseEntity<CollectionModel<EntityModel<Employee>>> findAll() {
List<EntityModel<Employee>> employees = StreamSupport.stream(repository.findAll().spliterator(), false)
.map(employee -> new EntityModel<>(employee,
.map(employee -> EntityModel.of(employee,
linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(),
linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees")))
.collect(Collectors.toList());
return ResponseEntity.ok(
new CollectionModel<>(employees,
CollectionModel.of(employees,
linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel()));
}
----
@@ -133,7 +133,7 @@ To build a single resource, the `/employees/{id}` route is shown below:
ResponseEntity<EntityModel<Employee>> findOne(@PathVariable long id) {
return repository.findById(id)
.map(employee -> new EntityModel<>(employee,
.map(employee -> EntityModel.of(employee,
linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(),
linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees")))
.map(ResponseEntity::ok)

View File

@@ -57,13 +57,13 @@ class EmployeeController {
ResponseEntity<CollectionModel<EntityModel<Employee>>> findAll() {
List<EntityModel<Employee>> employees = StreamSupport.stream(repository.findAll().spliterator(), false)
.map(employee -> new EntityModel<>(employee, //
.map(employee -> EntityModel.of(employee, //
linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), //
linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) //
.collect(Collectors.toList());
return ResponseEntity.ok( //
new CollectionModel<>(employees, //
CollectionModel.of(employees, //
linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel()));
}
@@ -73,7 +73,7 @@ class EmployeeController {
try {
Employee savedEmployee = repository.save(employee);
EntityModel<Employee> employeeResource = new EntityModel<>(savedEmployee, //
EntityModel<Employee> employeeResource = EntityModel.of(savedEmployee, //
linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel());
return ResponseEntity //
@@ -94,7 +94,7 @@ class EmployeeController {
ResponseEntity<EntityModel<Employee>> findOne(@PathVariable long id) {
return repository.findById(id) //
.map(employee -> new EntityModel<>(employee, //
.map(employee -> EntityModel.of(employee, //
linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), //
linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) //
.map(ResponseEntity::ok) //