public interface UserRepository extends MongoRepository<User, Long> {
User findByUsername(String username);
}
the above code uses the function of Spring JPA to find users according to their names, but multiple data can be queried in the database according to their names zong
, and the return value of the findByUsername method is User, not List < User >. At this time, the expected result should be an error, but the program does not report an error, but returns the first item of multiple data.
excuse me, what is the reason for this? why did you report it correctly?