Spring boot 如何使用spring boot和postman测试重置密码请求?
我目前正在为用户重新设置密码,测试该方法时遇到问题。代码如下:Spring boot 如何使用spring boot和postman测试重置密码请求?,spring-boot,jpa,Spring Boot,Jpa,我目前正在为用户重新设置密码,测试该方法时遇到问题。代码如下: @PostMapping("/user/resetPassword") public GenericResponse resetPassword(HttpServletRequest request, @RequestBody String userEmail) { System.out.println("Here we are in the method of the reset **
@PostMapping("/user/resetPassword")
public GenericResponse resetPassword(HttpServletRequest request, @RequestBody String userEmail) {
System.out.println("Here we are in the method of the reset *********");
User user = userRepository.findByEmail1(userEmail);
System.out.println ( user.getId());
System.out.println("This is my user"+user);
if (user == null) {
throw new UserNotFoundException();
}
String token = UUID.randomUUID().toString();
userService.createPasswordResetTokenForUser(user, token);
mailSender.send(constructResetTokenEmail(getAppUrl(request), request.getLocale(), token, user));
return new GenericResponse(messages.getMessage("message.resetPasswordEmail", null, request.getLocale()));
}
问题在于findByEmail中,它没有从我在邮递员有效负载的JSON中插入的电子邮件返回用户:
User findByEmail(String email);
执行的结果是UserNotFoundException。`userRepository.findByEmail1(userEmail);`是您创建了findByEmail1方法,还是它是一个打字错误?这个问题几乎没有找到实际问题的细节。您是否已验证用户存储库的配置是否正确?您是否已打印userEmail参数以确保其正确?你为什么叫“findByEmail1”(如果你的列名是email,通常是“findByEmail1”)?您还可以发布您的UserRepository类和用户实体以获取解决方案。我已经创建了它,还尝试了一个打字错误@TuhinKantiSharma@ShankarPS是的,当调试被看到时,我在邮件中做了所有的工作,所以它是通过json@Ella,可能是您可以编辑您的问题以添加您的用户位置。目前,你的问题似乎不完整。