Spring data报错:Inferred type ‘S’ for type parameter ‘S’ is not within its bound;
参照 org.springframework.data.repository.query.QueryByExampleExecutor
源码:
findOne
:
/**
* Returns a single entity matching the given {@link Example} or {@literal null} if none was found.
*
* @param example must not be {@literal null}.
* @return a single entity matching the given {@link Example} or {@link Optional#empty()} if none was found.
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the Example yields more than one result.
*/
<S extends T> Optional<S> findOne(Example<S> example);
参照 org.springframework.data.repository.CrudRepository
源码:
findById
:
/**
* Retrieves an entity by its id.
*
* @param id must not be {@literal null}.
* @return the entity with the given id or {@literal Optional#empty()} if none found
* @throws IllegalArgumentException if {@code id} is {@literal null}.
*/
Optional<T> findById(ID id);
findOne(id)
用 findById(id).orElse(null)
替换即可。