这是我的文档POJO
@Document(collection =“ users”) 公共类Employee实现Serializable {
@Id
private UUID id;
private String firstName;
private String lastName;
private String email;
public UUID getId() {
return id;
}
public void setId(UUID 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;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Employee)) return false;
Employee employee = (Employee) o;
if (!getId().equals(employee.getId())) return false;
if (getFirstName() != null ? !getFirstName().equals(employee.getFirstName()) : employee.getFirstName() != null)
return false;
if (getLastName() != null ? !getLastName().equals(employee.getLastName()) : employee.getLastName() != null)
return false;
return getEmail().equals(employee.getEmail());
}
@Override
public int hashCode() {
int result = getId().hashCode();
result = 31 * result + (getFirstName() != null ? getFirstName().hashCode() : 0);
result = 31 * result + (getLastName() != null ? getLastName().hashCode() : 0);
result = 31 * result + getEmail().hashCode();
return result;
}
}
这是我的存储库界面
@Repository
public interface EmployeeRepository extends
ReactiveMongoRepository<Employee, UUID> {
}
3。这是我的服务员
@Component
public class EmployeeHandler {
@Autowired
private EmployeeRepository employeeRepository;
public Mono<ServerResponse> createNewEmployee(ServerRequest request) {
Mono<Employee> employeeMono = request.bodyToMono(Employee.class);
Mono<Employee> newEmployee = employeeRepository.save(employeeMono);
return ServerResponse.ok()
.contentType(MediaType.APPLICATION_JSON)
.build(newEmployee);
}
}
编译错误,我在行“类型参数'S'的推断类型'S'不在其范围内;应扩展'com.kj.webfluxcruddemo.entity.Employee'”
Mono<Employee> newEmployee = employeeRepository.save(employeeMono);