Unit Testing Rest Services with Spring Boot and JUnit
问题 I have a basic SpringBoot app. using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. I've defined this Rest method to get a User @GetMapping(path = "/api/users/{id}", consumes = "application/json", produces = "application/json") public ResponseEntity<User> getUser (HttpServletRequest request, @PathVariable long id) { User user = checkAccess(request, id); return ResponseEntity.ok(user); } I've created this Junit to test it