完整的源代码演示应用程序可以在这里看到github.com网站
Source code link
这是我的文档类:
@Document(collection = "users")
public class Employee implements Serializable {
@Id
private String id = UUID.randomUUID().toString();
private String firstName;
private String lastName;
private String email;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
public Mono<ServerResponse> deleteAnEmployee(ServerRequest request) {
String employeeId = request.pathVariable("id");
return employeeRepository.findById(employeeId)
.flatMap(employee -> {
employeeRepository.delete(employee);
return ServerResponse.ok().build();
}).switchIfEmpty(ServerResponse.notFound().build());
}
我是不是漏了什么suggest.pom路由器、repo等请参阅描述中提供的gihub链接。