【发布时间】:2018-07-11 14:06:17
【问题描述】:
当我尝试显示指定用户的假期时。我有
URL: localhost:8080/api/user -> this getting me all users.
localhost:8080/api/user/userId (like 22)/vacation -> this should be getting me all Vacations for this user.
我在有这个方法的地方创建了 VacationController
@GetMapping("/api/user/{userId}/vacation")
public Vacation getVacations(@PathVariable Long userId) {
return vacationService.findAllByUserId(userId);
}
在我的服务中,此方法回答存储库具有:
@Repository
public interface VacationRepository extends JpaRepository<Vacation, Long> {
Vacation findAllByUserId(Long userId);
}
根据我在互联网上的研究,我已经正确编码,但它不起作用。我做错了什么?
【问题讨论】:
标签: java spring-boot spring-repositories