Java 在SpringBoot中正确获取控制器设置

Java 在SpringBoot中正确获取控制器设置,java,spring-boot,spring-repositories,Java,Spring Boot,Spring Repositories,当我尝试显示指定用户的假期时。我有 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

当我尝试显示指定用户的假期时。我有

 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);
}
@存储库
公共界面VacationRepository扩展了JpaRepository{
假期findAllByUserId(长用户id);
}

根据我在互联网上的研究,我已经正确地编码了这个,但它不起作用。我做错了什么?

你说的“它不工作”是什么意思?有错误代码吗

尝试更改:

 Vacation findAllByUserId(Long userId);
至(findAll返回集合):

列出findAllByUserId(长用户id);

请将错误张贴在您的question@Deeadline发布一个项目构建文件(maven为pom.xml,gradle为gradle.build)和用户实体
List<Vacation> findAllByUserId(Long userId);