Java 无法调试控制器-Spring引导中的@ExceptionHandler(ConstraintViolationException.class)

Java 无法调试控制器-Spring引导中的@ExceptionHandler(ConstraintViolationException.class),java,spring-boot,exceptionhandler,Java,Spring Boot,Exceptionhandler,是否有任何方法可以调试下面显示的异常处理程序,从postman传递无效请求不会导航到异常处理程序方法 @RequestMapping(“api/v1/employee”) @RestController 公共类EmployeeController{ 私人最终雇员服务雇员服务; 公共员工控制员(员工服务员工服务){ this.employeeService=employeeService; } @GetMapping({”/{empId}}) 公共响应性getEmployeeById(@PathV

是否有任何方法可以调试下面显示的异常处理程序,从postman传递无效请求不会导航到异常处理程序方法

@RequestMapping(“api/v1/employee”)
@RestController
公共类EmployeeController{
私人最终雇员服务雇员服务;
公共员工控制员(员工服务员工服务){
this.employeeService=employeeService;
}
@GetMapping({”/{empId}})
公共响应性getEmployeeById(@PathVariable(“empId”)UUID empId){
返回新的ResponseEntity(employeeService.getEmployeeById(empId),HttpStatus.OK);
}
@SuppressWarnings({“rawtypes”,“unchecked”})
@邮戳
public ResponseEntity createEmployee(@Valid@RequestBody EmployeeDto EmployeeDto){
EmployeeDto savedeemployeedto=employeeService.saveNewEmployee(EmployeeDto);
HttpHeaders=新的HttpHeaders();
headers.add(“Location”、“api/v1/employee/”+savedeemployeedto.getId().toString());
返回新的ResponseEntity(标题,HttpStatus.CREATED);
}
@SuppressWarnings({“rawtypes”})
@PutMapping({”/{empId}})
public ResponseEntity updateEmployee(@PathVariable(“empId”)UUID empId,@Valid@RequestBody EmployeeDto EmployeeDto){
employeeService.updateEmployee(empId,employeeDto);
返回新的响应状态(HttpStatus.NOT_IMPLEMENTED);
}
@DeleteMapping({”/{empId}})
@ResponseStatus(HttpStatus.未实现)
public void deleteEmployee(@PathVariable(“empId”)UUID empId){
employeeService.deleteEmployeeById(empId);
}
@ExceptionHandler(ConstraintViolationException.class)
私有响应验证ErrorHandler(ConstraintViolationException ex){
List validationErrors=new ArrayList(例如getConstraintViolations().size());
例如:getConstraintViolations().forEach(冲突->{
validationErrors.add(invalition.getPropertyPath()+“_”+invalition.getMessage());
});
返回新的响应属性(validationErrors,HttpStatus.BAD_请求);
}
}
传递无效请求不会在响应中显示验证错误

public class EmployeeDto {

@Null
private UUID id;

@Null
private Integer version;

@NotBlank
private String name;

@Min(18) @Max(60)
private Integer age;

@Null
private OffsetDateTime createdDate;

@Null
private OffsetDateTime lastModifiedDate;

@NotNull
private OffsetDateTime joiningDate;

@NotNull
private EmployeeType employeeType;

@NotNull
@Positive
private BigDecimal salary;
}


添加了用于参考的Employee Dto类。,

能否显示Employee Dto?您是否在类中定义了JSR303bean验证注释?