Inferred type 'S' for type parameter 'S' is not within its bound; should extend 'ua.com.store.entity.Country

Spring documentation defines methods getOne as follows

<S extends T> Optional<S> findOne(Example<S> example)

In your method your input parameter is 'id' of type int but not bounded to interface Example.

To find an entity with it 'id' you can use the method

Optional<T> findById(ID id)

According to your implementation you may write it

@Override
public Country findOne(int id) {
    return dao.findById(id);
}

It is possible to be relevant about spring-boot version. I meet the same issue when my spring-boot version is 2.0.1.RELEASE. But after change the spring-boot version to the 1.5.9.RELEASE, it is resolved.


A 100% working solution is following:

@Override
public Country findOne(int id) {
    return dao..findById(id).orElse(null);
}