Java 如何使用findById()在数据库中搜索字符串id?

Java 如何使用findById()在数据库中搜索字符串id?,java,mysql,spring-data-jpa,findby,Java,Mysql,Spring Data Jpa,Findby,如何按ID搜索字符串Pathvariable而不是整数?我喜欢找名字 下面的方法可以很好地工作,但只需要将ID作为整数值 谢谢: @RestController @RequestMappingvalue=/etbestandservice 公共类ETBestandserviceController{ @自动连线 ETBEST和服务存储库ETBEST和EPOS; @GetMappingvalue=/find/{id},products=application/json 公共选修课findErsat

如何按ID搜索字符串Pathvariable而不是整数?我喜欢找名字

下面的方法可以很好地工作,但只需要将ID作为整数值

谢谢:

@RestController @RequestMappingvalue=/etbestandservice 公共类ETBestandserviceController{ @自动连线 ETBEST和服务存储库ETBEST和EPOS; @GetMappingvalue=/find/{id},products=application/json 公共选修课findErsatzteile@PathVariableid整数id,ETBestandservice等{ id=et.getId; 返回etbestandRepos.findByIdid; } } 在Spring JPA ETBestandserviceRepository接口中添加一个可选的findByNameString名称方法,Spring将在启动时为您生成预期的查询。 如果查询可能返回多个结果,请将可选替换为列表。
更多信息

你能澄清一下你的问题吗?我已经试过了,但对我不起作用。我得到这个异常:UnsatifiedPendencyException:创建名为“ETBestandserviceController”的bean时出错:通过字段“etbestandRepos”表示的未满足的依赖关系;此异常与query@volkanbcheck this@volkanb无关