我是一只咸鱼

导航

spring boot jpa 无法使用findOne

(findOne(id))说我无法转换成相应的类型,换一种即可,如下:

 

1 user = userRepository.findOne(id);//spring 2.x用不了
2 
3 @GetMapping("/user/{id}")
4     public User getUser(@PathVariable("id") Integer id){
5         User user;
6         user = userRepository.findById(id).orElse(null);
7         return user;
8     }

 

posted on 2019-05-21 16:57  我是一只咸鱼  阅读(264)  评论(0编辑  收藏  举报