问题实例:findOne不能传入ID
问题原因:自从spring boot 2.0以后,由于用上了Java 8 的Option,废除了findone(Id)。
解决办法有两种:
1.降低SpringBoot版本
将SpringBoot版本改为 1.5.6之后,findOne可以传入ID了
2.使用findById代替findOne,或者构造Example
//直接用findById查找
xxxx.findById(id:1).orElse(other:null);
//Example
Plus plus = new Plus();
plus.setId(1);
Example<Plus> example = Example.of(plus);
Optional<Plus> optional = plusRepository.findOne(example);