下面是完整的代码。它向UserNotFoundException抛出了一个错误。
@RestController
public class UserResource {
//GET /users/{id}
//retrieveUser(int id)
@GetMapping("/users/{id}")
public User retrieveUser(@PathVariable int id) {
User user = service.findone(id);
if(user==null)
throw new UserNotFoundException("id-"+ id); //this throwing the error.
return user;
}
}
发布于 2020-11-17 14:47:37
UserNotFoundException
听起来像是您自己定义的一个异常。所以我猜你必须导入它:
import yourpackage.UserNotFoundException
https://stackoverflow.com/questions/64850448
复制相似问题