Inferred type 'S' for type parameter 'S' is not within its bound

Posted ming-blogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Inferred type 'S' for type parameter 'S' is not within its bound相关的知识,希望对你有一定的参考价值。

springboot报错内容:
Inferred type ‘S’ for type parameter ‘S’ is not within its bound; should extends xxxxxx

/*

  1. * 根据id查询
  2. */
  3. @GetMapping("/student/{id}")
  4. public Student findById(@PathVariable("id") Integer id){
  5. return studentRespository.findOne(id);
  6. }

用以上方法findOne(id);报错,经过网上查询资料最后找到原因。解决办法如下,
1、springboot 版本问题,将 2.0.1 版本换成 1.5.4 版本。
2、将studentRespository.findOne(id); 改为 studentRespository.findById(id).orElse(null);
3、将studentRespository.findOne(id); 改为
return studentRespository.findById(id).get();
4、将studentRespository.findOne(id); 改为
return studentRespository.getOne(id);
以上三种办法,第二、三种方法本人试验过可以使用,第一种本人没进行验证,如有需要可以自行验证。第四种方法进行验证因为jdk版本原因并未成功,所有推荐大家使用第二三种方法。

以上均来自个人验证。

 








以上是关于Inferred type 'S' for type parameter 'S' is not within its bound的主要内容,如果未能解决你的问题,请参考以下文章

TypeError: unsupported operand type(s) for /: 'map' and 'int'

Element 'beans' cannot have character [children],because the type's content type is elem

python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

错误记录Kotlin 编译报错 ( Type mismatch: inferred type is String? but String was expected )

[GraphQL] Use GraphQL's Object Type for Basic Types

pom文件出现Element 'xxxxxxx' cannot have character [children],because the type's content typ