Can't use method findOne() in Spring boot
Your UserRepository
is defined as CrudRepository<User,String>
. Where User
is the type and String
the type of the id. However your User
class has an id field of the type int
NOT of type String
.
First fix your UserRepository
to be a proper representation of your User
.
public interface UserRepository extends CrudRepository<User, Integer> {}
Next create a method to find your User
by name.
public User findByName(String name);
And call this from your controller instead of findOne
. The findOne
is used to find entities based on ID not on any random field of your entity.